MSDN Documentation

SQL Server Relational Databases

Core Concepts of Relational Databases

Relational databases are a fundamental technology for data storage and management. They are based on the relational model, which organizes data into one or more tables (also known as relations) of columns and rows. Each table represents an entity type, and each row represents an instance of that entity type. Each column represents an attribute of the entity.

Tables and Columns

A table is a structured set of data with columns organized in columns and rows. Think of it like a spreadsheet. The columns define the type of data that will be stored, while the rows contain the actual data.

A column (or attribute) is a vertical entity in a table that contains all the data values for a specific attribute. Each column has a name and a data type (e.g., integer, text, date).

Rows and Records

A row (or tuple/record) is a horizontal entity in a table that represents a single instance of the entity described by the table. Each row contains a value for each column.

Keys

Keys are essential for uniquely identifying rows and establishing relationships between tables.

Primary Key

A primary key is a column or a set of columns that uniquely identifies each row in a table. It cannot contain NULL values and must have unique values for every row. A table can have only one primary key.

Primary keys enforce entity integrity, ensuring that each record is distinct.

Foreign Key

A foreign key is a column or a set of columns in one table that refers to the primary key in another table. It is used to establish and enforce a link (relationship) between the two tables.

For example, in an `Orders` table, a `CustomerID` column could be a foreign key referencing the `CustomerID` primary key in a `Customers` table. This ensures that every order is associated with a valid customer.

Relationships

Relational databases support several types of relationships between tables:

SQL (Structured Query Language)

SQL is the standard language used to communicate with and manipulate relational databases. It allows you to perform operations such as:

Here's a simple example of a SQL query:


SELECT customer_name, email
FROM customers
WHERE city = 'London';
            

Normalization

Normalization is a database design technique used to reduce data redundancy and improve data integrity. It involves organizing columns and tables to ensure that dependencies are properly enforced by database integrity constraints. Normal forms (1NF, 2NF, 3NF, etc.) provide guidelines for achieving this.

Understanding these core concepts is crucial for effective database design and management.

Further Reading