Relational Database Concepts
1. Flat-file vs. Relational Databases
All data is stored in a single table. This leads to Data Redundancy (repeating the same info) and Data Inconsistency (typos in repeated data).
Data is split into multiple, related tables. This ensures Data Integrity and allows for complex queries across different entities.
2. Key Terminology
| Term | A-Level Definition | Alternative Name |
|---|---|---|
| Entity | An object or concept about which data is stored (e.g., Student, Course). | Table |
| Attribute | A characteristic of an entity (e.g., StudentName). | Field / Column |
| Tuple | A single instance of an entity. | Record / Row |
3. The "Keys" to the Database
- Primary Key (PK): A unique identifier for every record in a table (e.g.,
StudentID). - Foreign Key (FK): An attribute in one table that is a Primary Key in another. It creates the link between tables.
- Composite Key: A primary key made of two or more attributes combined to ensure uniqueness.
4. Entity-Relationship (E-R) Models
E-R Diagrams show how tables are linked. At AS-Level, you must understand three types of relationships:
2. One-to-Many (1:M) — e.g., Teacher to Students.
3. Many-to-Many (M:N) — e.g., Students to Courses.
A relational database cannot handle a direct Many-to-Many link. You must resolve it by creating a Link Table (Join Table) in the middle, turning the relationship into two One-to-Many links.
This is a rule that ensures consistency. You cannot have a Foreign Key value in the "Many" table that doesn't exist as a Primary Key in the "One" table. (e.g., You can't assign a student to a CourseID that doesn't exist).