SQL Server Fundamentals
SQL Server fundamentals introduce the basic concepts required to work with databases, tables, SQL queries and the SQL Server database engine.
What is SQL Server?
SQL Server is a relational database management system (RDBMS) developed by Microsoft. It is used to store, manage and retrieve structured data.
SQL Server uses SQL (Structured Query Language) to communicate with databases and perform operations such as inserting, retrieving, updating and deleting data.
What is a Database?
A database is an organized collection of data that allows information to be stored and managed efficiently.
In SQL Server, a database can contain tables, views, stored procedures, functions and other database objects.
Example
A college database may contain student information, course information, faculty information and examination records.
What is a Table?
A table is used to store data in rows and columns. Each table represents a particular type of information.
For example, a Students table can contain information about students.
| StudentId | Name | Course | |
|---|---|---|---|
| 1 | Rahul | rahul@example.com | .NET |
| 2 | Priya | priya@example.com | Java |
| 3 | Amit | amit@example.com | Python |
Rows and Columns
A table is made up of rows and columns.
- Column: Defines a particular type of data.
- Row: Represents one complete record.
What is SQL?
SQL stands for Structured Query Language. It is used to communicate with relational databases.
SQL allows developers and database administrators to perform different operations on database data.
| Operation | Purpose |
|---|---|
| SELECT | Retrieve data from a database. |
| INSERT | Add new data to a table. |
| UPDATE | Modify existing data. |
| DELETE | Remove data from a table. |
Basic SQL Query
The following query retrieves all records from the Students table.
SELECT * FROM Students;
How SQL Server Works
A client application sends a SQL query to SQL Server. SQL Server processes the query and communicates with the database engine to retrieve or modify the required data.
Client Application
↓
SQL Query
↓
SQL Server
↓
Database Engine
↓
Database
↓
Result
The Database Engine processes the SQL statement and returns the requested result to the client application.
Common SQL Server Database Objects
SQL Server databases contain different objects that are used to store data and implement database functionality.
| Object | Purpose |
|---|---|
| Tables | Store data in rows and columns. |
| Views | Provide a virtual representation of data. |
| Stored Procedures | Store reusable SQL statements and logic. |
| Functions | Perform reusable operations and return values. |
| Triggers | Automatically execute in response to database events. |
CRUD Operations
CRUD represents the four basic operations performed on database data.
| Operation | SQL Command | Purpose |
|---|---|---|
| Create | INSERT | Add new records. |
| Read | SELECT | Retrieve records. |
| Update | UPDATE | Modify records. |
| Delete | DELETE | Remove records. |
Summary
In this section, we learned the fundamentals of SQL Server, databases, tables, rows and columns, SQL queries, database objects and CRUD operations. These concepts provide the foundation for working with SQL Server databases.