0% found this document useful (0 votes)
2 views8 pages

Chapter 4 - The Relational Model

The Relational Model, established by Edgar F. Codd in 1970, is the cornerstone of modern database systems, organizing data into structured tables based on set theory and logic. It emphasizes simplicity, data integrity, and SQL compatibility, while employing keys and constraints to maintain data accuracy and relationships. Relational algebra operations such as selection, projection, and join facilitate efficient data manipulation and retrieval, solidifying the model's status as the most widely used in database management.

Uploaded by

Dalisay Bersabal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

Chapter 4 - The Relational Model

The Relational Model, established by Edgar F. Codd in 1970, is the cornerstone of modern database systems, organizing data into structured tables based on set theory and logic. It emphasizes simplicity, data integrity, and SQL compatibility, while employing keys and constraints to maintain data accuracy and relationships. Relational algebra operations such as selection, projection, and join facilitate efficient data manipulation and retrieval, solidifying the model's status as the most widely used in database management.

Uploaded by

Dalisay Bersabal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

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.

Comparison with Other Database Models


 Hierarchical Model: Uses a tree-like structure where each parent node has multiple
children, making traversal strict and complex.
 Network Model: Uses graph structures with multiple parent-child relationships, allowing
more flexibility but requiring complex pointer navigation.
 Object-Oriented Model: Integrates database operations with object-oriented
programming, supporting complex data types but requiring specialized databases.

Figure 1. Relational Model


Core Concepts of the Relational Model
1. Relation (Table): Definition and Structure
A relation is a two-dimensional table consisting of rows (tuples) and columns (attributes).
Each table represents a specific entity type (e.g., Students, Courses).

2. Tuple (Row): Representation of Records


A tuple represents a single record or instance in the table.
 Example: A single student's information in the "Students" table is a tuple.

3. Attribute (Column): Characteristics of a Relation


Attributes represent the properties or characteristics of the entities.
 Example: Name, Roll Number, and CGPA are attributes of the "Students" table.

4. Domain: Constraints on Attribute Values


The domain defines the range of valid values for an attribute.
 Example: The domain of the "Age" attribute could be restricted to positive integers.

5. Schema vs. Instance


 Schema: The blueprint defining table structures, relationships, and constraints.
 Instance: The actual data stored in the database at a specific point in time.

Relational Keys and Constraints


Relational keys and constraints are fundamental concepts in the relational model of databases.
They define how data is organized, accessed, and enforced to ensure data consistency and
integrity within relational tables.

Figure 2. Relational Keys Example


These are of the following types:
 Primary Key
A primary key is an attribute (or a set of attributes) that uniquely identifies each tuple
(row) in a relation (table). It ensures that no two rows have the same value in the primary
key column(s), providing a unique identity for every record.
o Key Features of Primary Key:
o Uniqueness: Ensures that each tuple has a unique identifier.
o Non-Null Constraint: Primary keys cannot have null values, as every record
must be identifiable.

 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.

 Referential Integrity Constraint:


Ensures foreign key values reference valid tuples in the parent table or remain null.
o Example: Every enrollment in the "Enrollments" table must refer to a valid
Course_ID in the "Courses" table.

 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.

Importance of Relational Keys and Constraints


 Data Integrity: Keys and constraints ensure that the data within and across tables is
consistent and accurate.
 Data Validation: Constraints like domain constraints validate that inputs adhere to
defined rules.
 Relationships: Foreign keys establish meaningful connections between tables, enabling
logical data organization.
 Query Reliability: Well-defined keys and constraints ensure reliable and predictable
query results.

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.

2. Projection (π) – Selecting Columns


 The Projection operation selects specific columns (attributes) from a relation.
 It filters data vertically by removing unwanted columns.
 Duplicate values are automatically eliminated.
Relational Algebra Notation:
πattribute list(R)
SQL Equivalent:
SELECT Name, Salary FROM Employee;
Example:
The relational algebra query:
πName, Salary(Employee)
retrieves only the Name and Salary attributes from the Employee relation
3. Join (⨝) – Combining Relations
 The Join operation combines two relations based on a related attribute.
 It helps in retrieving data from multiple tables.
 Types of Joins:
o Theta Join (θ-Join) → Uses a general condition (R ⨝ condition S).
o Equi-Join → Uses an equality condition (e.g., R ⨝ R.A = S.B S).
o Natural Join (⋈) → Automatically joins relations based on common
attributes.
Relational Algebra Notation:
R⋈conditionS

SQL Equivalent:
SELECT Employee.EmpID, Employee.Name, Department.DeptName

FROM Employee

INNER JOIN Department ON Employee.DeptID = Department.DeptID;

Example:
Given:
 Employee(EmpID, Name, DeptID)
 Department(DeptID, DeptName)
The relational algebra query:
Employee⋈Employee.DeptID=Department.DeptIDDepartment

retrieves employees along with their department names.

4. Union (∪) – Merging Relations


 The Union operation returns all tuples from relations R and S, removing
duplicates.
 Conditions for Union:
o R and S must have the same schema (same attributes and data types).
Relational Algebra Notation:
R∪S

SQL Equivalent:
SELECT EmpID, Name, Salary FROM Employees

UNION

SELECT EmpID, Name, Salary FROM Managers;

Example:
If Managers(EmpID, Name, Salary) and Employees(EmpID, Name, Salary) have the same
schema:
Managers∪Employees

retrieves all unique employees and managers

5. Intersection (∩) – Common Tuples


 The Intersection operation returns only the common tuples that exist in both
relations R and S.
Relational Algebra Notation:
R∩S

SQL Equivalent:
SELECT EmpID, Name FROM ProjectA_Employees

INTERSECT

SELECT EmpID, Name FROM ProjectB_Employees;

6. Difference (-) – Subtracting Tuples


 The Difference operation returns tuples that exist in relation R but not in relation
S.
Relational Algebra Notation:
R−S
SQL Equivalent:
SELECT EmpID, Name FROM Employees

EXCEPT

SELECT EmpID, Name FROM Managers;

Example:
Given:
 Employees(EmpID, Name, Salary)
 Managers(EmpID, Name, Salary)

The relational algebra query:


Employees−Managers

retrieves employees who are not managers.

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.

You might also like