Chapter 4 - The Relational Model
Chapter 4 - The Relational Model
The Relational Model serves as the foundation for modern database systems, defining how data
is structured, stored, and manipulated in relational databases. This module provides an in-depth
exploration of its history, core concepts, keys, constraints, properties, operations, and
advantages, enabling students to understand why it is one of the most widely used database
models.
Introduction
The relational model is a formal structure for organizing and managing data using tables
(relations). Introduced by Edgar F. Codd in 1970, it revolutionized database management by
providing a structured, mathematical foundation for storing and manipulating data. The model
is built on set theory, tuple relational calculus, and first-order predicate logic, ensuring data
independence, consistency, and integrity.
Importance of the Relational Model
The relational model is the backbone of modern database systems due to its:
Structural Simplicity: Data is stored in well-defined tables with clear relationships.
Mathematical Foundation: Based on rigorous principles, ensuring reliability and
efficiency.
Data Integrity and Security: Enforces constraints to maintain accuracy.
SQL Compatibility: Supports the most widely used query language for efficient data
management.
Scalability and Flexibility: Easily accommodates growing datasets and business
requirements.
Candidate Key
A candidate key is an attribute or set of attributes that can uniquely identify tuples in a
relation. It is a potential candidate for becoming the primary key.
o Key Features of Candidate Key:
o A relation can have multiple candidate keys.
o Candidate keys must satisfy uniqueness and non-null properties.
Super Key
A super key is any set of attributes that can uniquely identify tuples in a relation,
including candidate keys and additional attributes. It is essentially a superset of a
candidate key, meaning it may contain attributes that are not necessary for unique
identification.
o Key Features of Super Key:
o All primary keys and candidate keys are super keys.
o Super keys may include extra attributes that are irrelevant for unique
identification.
Foreign Key
A foreign key is an attribute in one relation that references the primary key of another
relation. It creates a link between two tables, enabling referential integrity.
o Key Features of Foreign Key:
o Ensures consistency between related tables.
o Enforces valid relationships between parent and child tables.
o Foreign keys can have null values if the relationship is optional.
Constraints
Constraints enforce rules on data in tables to maintain data integrity and consistency. They
ensure that the database adheres to the defined schema and logical structure.
The main constraints are:
Entity Integrity Constraint:
Ensures the primary key is unique and non-null.
o Example: Every student in the "Students" table must have a valid, non-null
Student_ID.
Domain Constraints:
Define the permissible range or set of values for an attribute.
o Example: The Age attribute in the "Students" table can have a domain constraint
of positive integers between 18 and 30.
Key Constraints:
Ensure the uniqueness of keys like primary keys and candidate keys.
o Example: No two students can have the same Student_ID.
Relational Operations
Basic Relational Algebra Operations
Relational algebra uses operations to retrieve and manipulate data stored in relations (tables).
Each operation produces a new relation as its result.
Here are the fundamental operations:
1. Selection (σ) Filtering Rows
The Selection operation retrieves specific rows (tuples) from a relation that satisfy
a given condition.
It filters data horizontally by selecting only those records that match the specified
condition.
Relational Algebra Notation:
σcondition(R)
SQL Equivalent:
SELECT * FROM Employee WHERE Salary > 50000;
Example:
Given a relation Employee(EmpID, Name, Salary, DeptID), the relational algebra query:
σSalary>50000(Employee)
retrieves employees with a salary greater than 50,000.
SQL Equivalent:
SELECT Employee.EmpID, Employee.Name, Department.DeptName
FROM Employee
Example:
Given:
Employee(EmpID, Name, DeptID)
Department(DeptID, DeptName)
The relational algebra query:
Employee⋈Employee.DeptID=Department.DeptIDDepartment
SQL Equivalent:
SELECT EmpID, Name, Salary FROM Employees
UNION
Example:
If Managers(EmpID, Name, Salary) and Employees(EmpID, Name, Salary) have the same
schema:
Managers∪Employees
SQL Equivalent:
SELECT EmpID, Name FROM ProjectA_Employees
INTERSECT
EXCEPT
Example:
Given:
Employees(EmpID, Name, Salary)
Managers(EmpID, Name, Salary)
Summary
The Relational Model, introduced by Edgar F. Codd in 1970, is the foundation of modern
databases, organizing data into structured relations (tables) based on set theory, tuple relational
calculus, and first-order predicate logic. It offers structural simplicity, data integrity, SQL
compatibility, and scalability, making it superior to hierarchical, network, and object-oriented
models. A relation consists of tuples (rows) and attributes (columns), with constraints ensuring
data consistency. Keys like primary, candidate, super, and foreign keys enforce uniqueness and
relationships between tables, while constraints such as entity integrity, referential integrity,
domain constraints, and key constraints maintain data accuracy and logical consistency.
Relational algebra provides operations for efficient data manipulation. Selection (σ) filters rows,
Projection (π) selects columns, and Join (⨝) combines tables. Union (∪) merges relations,
Intersection (∩) retrieves common tuples, and Difference (-) finds unique tuples in one table but
not another. These operations ensure efficient querying, retrieval, and management of data.
With its mathematical foundation, flexibility, and reliability, the relational model remains the
most widely used database model today.