Post

02. Introduction to Relational Model

02. Introduction to Relational Model

Structure of Relational Databases

Relation Schema and Instance

schema-example.png

  • Schema: R = (A1, A2, …, An)
  • A1, A2, …, An are attributes
  • Order of tuples is irrelevant

Domain

For each attribute of a relation, there is a set of permitted values

  • Attribute values(domain) are (normally) required to be atomic

    Atomic

    • A domain is atomic if elements of the domain are considered to be indivisible units

e.g. where domain for phone number isn’t atomic

EmployeeIDNamePhone Numbers
1John Doe555-1234, 555-5678
2Jane Smith555-8765, 555-4321

Null

Special value that signifies that the values is unknown or does not exist

Key

Super Key

Set of one or more attributes that, taken collectively, allow us to identify uniquely a tuple in the relation

Candidate key

Minimal super keys

Primary Key

Candidate key that is chosen by the database designer as the principal means of identifying tuples within a relation

Foreign Key

  • Constraint: Value in one relation must appear in another relation

    e.g.

    EmployeeID (PK)SSN (Candidate Key)Email (Candidate Key)NameDepartmentID (FK)
    1123-45-6789john.doe@example.comJohn Doe10
    2987-65-4321jane.smith@example.comJane Smith20
    DepartmentID (PK)DepartmentName
    10Sales
    20Engineering
    • Super Key: In the Employees table, any combination of attributes that uniquely identifies a row (e.g., {EmployeeID}, {SSN, Email}, etc.) is a super key.
    • Candidate Key: Minimal super keys that cannot be reduced further. Here, EmployeeID, SSN, and Email are potential candidate keys.
    • Primary Key: Out of the candidate keys, EmployeeID is chosen as the primary key.
    • Foreign Key: The DepartmentID in the Employees table must match a DepartmentID in the Departments table, ensuring referential integrity.
This post is licensed under CC BY 4.0 by the author.