Learn how relational tables represent facts and how keys connect them. These ideas help you read schemas, understand JOINs later, and avoid duplicate or inconsistent data.
Key Takeaways at a Glance:
- •A table represents an entity with a specific 'grain' (the exact real-world meaning of a single row).
- •A Primary Key uniquely identifies a row and strictly forbids NULLs; composite keys combine multiple columns.
- •A Foreign Key enforces referential integrity by pointing to an existing Primary Key in another relation.
- •One-to-many relationships require the foreign key on the 'many' side; many-to-many relationships require an associative junction table.
In Simple Words (The Mental Model)
Think of a spreadsheet where each tab is an entity. Instead of copying a department's name, floor, and budget onto every single employee row (which causes update anomalies and typos), you assign the department a unique number (Primary Key) and only store that number on the employee row (Foreign Key).
Real-World Analogy
Think of a passport. Your Passport Number is your Primary Key—unique to you alone, never null. When you check into an airport flight, the airline links your ticket to your Passport Number (Foreign Key). The airline doesn't need to re-record your entire medical history or DNA on the ticket; they just reference your passport.