Relational Data Model

Introduction to the Relational Model

The relational model is the most widely used data model for databases today. Developed by E.F. Codd at IBM in 1970, it organizes data into tables (called relations) that can be easily understood and manipulated.

Basic Concepts

Relations (Tables)

A relation is a two-dimensional table that represents a collection of related data entries. Each relation has:

  • A unique name
  • A set of attributes (columns)
  • A set of tuples (rows)

Example of a Relation (STUDENT table):

StudentIDFirstNameLastNameAgeDepartment
S101JohnSmith21Computer Science
S102MariaGarcia19Mathematics
S103AhmedKhan22Physics

Attributes (Columns)

Attributes are named columns in a relation that describe a particular characteristic of the data entity. Each attribute has:

  • A unique name within the relation
  • A data domain (the type of values it can contain)

In the STUDENT example above, the attributes are StudentID, FirstName, LastName, Age, and Department.

Tuples (Rows)

Tuples are individual records or rows in a relation. Each tuple contains one value for each attribute in the relation.

In the STUDENT example, there are three tuples, each representing one student’s information.

Domain

A domain is the set of allowable values for an attribute. For example:

  • The domain for Age might be positive integers less than 100
  • The domain for FirstName might be strings with a maximum of 50 characters

Properties of Relations

1. Relations Have No Duplicate Tuples

Each tuple in a relation must be unique. No two rows can have the exact same values for all attributes.

2. Relations Have No Ordering of Tuples

The order of rows in a relation does not matter. The meaning of the data is the same regardless of how the rows are arranged.

3. Relations Have No Ordering of Attributes

Conceptually, the order of columns does not matter (though in implementation, they often have a specific order).

4. All Attribute Values Are Atomic

Each cell in the table must contain only a single value, not a list of values or another relation. This is known as the “First Normal Form” requirement.

Degree and Cardinality

  • Degree: The number of attributes (columns) in a relation
    • The STUDENT relation above has a degree of 5
  • Cardinality: The number of tuples (rows) in a relation
    • The STUDENT relation above has a cardinality of 3

Keys in the Relational Model

Keys are important for establishing relationships between tables and ensuring data integrity:

1. Superkey

A set of attributes that can uniquely identify a tuple in a relation. A relation may have many superkeys.

2. Candidate Key

A minimal superkey, meaning no subset of it can uniquely identify tuples. A relation may have multiple candidate keys.

3. Primary Key

The chosen candidate key that will be used to identify tuples. Every relation must have exactly one primary key.

4. Foreign Key

An attribute or set of attributes in one relation that refers to the primary key of another relation. Foreign keys create relationships between tables.

Relationships in the Relational Model

Relationships between entities are represented through foreign keys:

1. One-to-One Relationship

When one record in a table is associated with exactly one record in another table.

Example: Each EMPLOYEE has one EMPLOYEE_DETAIL record.

2. One-to-Many Relationship

When one record in a table can be associated with multiple records in another table.

Example: One DEPARTMENT can have many EMPLOYEES.

3. Many-to-Many Relationship

When multiple records in a table can be associated with multiple records in another table. These relationships typically require a junction table.

Example: STUDENTS and COURSES - each student can take multiple courses, and each course can have multiple students.

Relational Schema

A relational schema is the structure of a relation, denoted as:

RELATION_NAME(attribute1, attribute2, ..., attributeN)

For example: STUDENT(StudentID, FirstName, LastName, Age, Department)

Primary keys are often underlined in schema notation: STUDENT(StudentID, FirstName, LastName, Age, Department)

Advantages of the Relational Model

  • Simplicity: The table structure is easy to understand
  • Flexibility: Easy to modify and extend
  • Data Independence: Physical storage changes don’t affect the logical structure
  • Integrity Constraints: Built-in rules help maintain data accuracy
  • Query Capability: Powerful query language (SQL) for data manipulation
  • Security: Fine-grained access control is possible

Limitations of the Relational Model

  • Performance: Can be slower for very complex relationships or large datasets
  • Complex Data: Not ideal for handling unstructured data
  • Impedance Mismatch: Gap between object-oriented programming and relational representation
  • Limited Semantic Expression: Some real-world relationships are difficult to model

The relational model remains the foundation of most database systems due to its simplicity, flexibility, and mathematical foundation based on set theory and relational algebra.