Overview of SQL Server
Microsoft created the relational database management system (RDBMS) known as SQL Server. It is frequently used in backend development to effectively manage, store, and retrieve data in business systems, online applications, and APIs. This is a brief introduction to SQL Server and its role in backend development.
Structured Query Language
SQL server is a relational database management system which is used to manage and access the data from database.SQL is a powerful language used to run queries, retrieve, insert, update, and delete records in a database. With help of SQL we can create a databases, tables, stored procedures, views, and manages permissions for these entities.
Why sql server: is used to create or design databases which are use to store information.
Data management: Large amounts of data may be effectively stored and managed in databases using SQL Server.
Data Security: Strong security protections are included, limiting access to data via encryption and permissions. Data Retrieval: Quick data retrieval is made possible by SQL Server’s rapid and effective querying.
Types of services:
- Database engine
- Analysis service
- Reporting service
- Integration service
- SQL server compact edition or mobile edition
Database Engine: It is used to manage and access the data from database, also manage and access data from the database, handling queries, transactions, and ensuring data integrity.
Analysis Service: this service can be used for data warehousing concepts
Reporting Service: can be used to generate reports from database, also Generates interactive reports from databases, supporting a variety of formats such as PDF, Excel, and HTML.
Integration Service: it can be used to convert from one relational database
tables to another.
SQL server compact edition: it can be used for mobile application
development also designed for mobile application development, providing a lightweight, embedded database for devices with limited resources.
SQL Command Set:
1.DDL(Data definition language) Data Definition language is used to specify structure of database how like tables, schemas, and indexes are organized Create,Alter,Drop
2.DML(Data Manipulation language) This is manages data within tables insert,delete,update
3.DCL(Data control language) allows or prohibits users from accessing data. Grant ,Revoke
4.TCL(Transaction control language) Database transactions are managed by TCL (Transaction Control Language), which uses commands like commit and rollback to guarantee data consistency. Rollback,commit,savepoint
5.DQL(Data Query language) select
Create:
is used to create table,database,function,procedures ,constraints etc
alter:
is used to modify the table structure like add column,drop column
or change column datatype or its sizeupdate:
is used to modify the table data or content or record
drop:
is used to drop the database or table or any thing permanently
delete:
is used to delete the data from the table
insert:
is used to insert records into table or to store the data
Constraints
constraint means condition ,it is nothing but rule and regulation about table it is used to avoid data duplication and repetition and make the data consistency.
Types of constraints:
1.Unique
2.Not null
3.Primary key
4.Check
5.Default
6.Foreign key
Unique: It is used to accept unique value will accept one null value not duplicate
Not Null: It is used to not accept any null value ,it will accept duplicate value.
Primary key: it will accept unique values ,it will not accept duplicate values, it will not accept null values. In SQL server a table should have only one primary key
more than one primary in a table not allowed.
Check: Check ensure that values in column satisfied a specific condition.
Default: Set the default values for a column if no values is specified.
Foreign key: it is used to maintain referential integrity between two table .it is used to maintain relationship between table, one table should be primary key other table should have foreign key
Temporary Table
Temporary tables are similar to permanent tables permanent tables gets create and stored permanently in database temporary tables gets create and stored temporarily in database these tables will be delete automatically when they are no longer use or when we close query window.
Another hand temporary table are most likely as permanent table , it is created in tempdb are automatically deleted as soon as last connection is terminated.
1 Local temp tables
2.Global temp tables
Local temp tables
these table names prefix with single # symbol these tables can only be access within same query window.
It is available only for session that has created it,and automatically deleted when connection that has created is closed.
Global temp tables
Global temporary table are visible to all connection and dropped when last connection refreshing is closed symbol is used for global temporary table is ##.
Another, these table names prefix with double ## symbol ,these tables can be access in any other query window. Multiple users can not create global temp tables with same name global temp table names not end with random number.
SQL Server in Backend Development
Data Storage: SQL Server uses tables to hold transaction records, product details, and user data. It makes SQL querying more effective.
Business Logic: By storing business logic in triggers and stored procedures, you can make queries reusable and offload work from the app server.
Scalability: By adding resources or splitting up data, SQL Server can accommodate growing loads both vertically and horizontally.
Security: With role-based authorization, encryption to safeguard sensitive data, and authentication, SQL Server provides strong security.
Integrates seamlessly with.NET for data access and manipulation utilizing T-SQL using ADO.NET, Entity Framework, and Dapper.
Backup/Recovery: Offers dependable choices for data preservation and recovery in the event of malfunctions.
Supports both reporting (SSRS) and analytics (SSAS) for backend management of big datasets.
Common Use Cases:
User Authentication: Stores and manages user credentials for login processes.
APIs: Handles data storage for product catalogs, orders, and transactions in backend services.
E-Commerce: Manages inventory, sales, and user activity data.
Data Warehousing: Supports data storage and analysis for large datasets used in reporting and business intelligence.
All topic are covered in this artical
This was a great introduction to SQL Server. It helped me understand the different editions and features!