MySQL Database
Relational Thinking and Table Design
Relational databases store facts once, in the right table, connected by keys. Good design prevents the update-anomaly chaos that spreadsheet-style data suffers.
Key Concepts
- Tables have typed columns and rows of records; each table models one entity (students, courses)
- PRIMARY KEY uniquely identifies each row — usually an AUTO_INCREMENT id
- FOREIGN KEY columns reference other tables' primary keys, forming relationships
- One-to-many: one category, many questions; many-to-many needs a junction table
- Normalisation in one sentence: don't store the same fact twice
Try It Yourself
Design on paper the tables for a school: students, subjects and marks. Mark primary keys, foreign keys and the one many-to-many relationship.
Lessons
▶️ 1. Relational Thinking and Table Design
▶️ 2. Types, Creation and Constraints
▶️ 3. Reading Data: SELECT
▶️ 4. Writing Data: INSERT, UPDATE, DELETE
▶️ 5. JOINs: Answering Cross-Table Questions
▶️ 6. Aggregation and Indexes
▶️ 7. Subqueries, Views and CASE Logic
▶️ 8. Backup, Users and Production Care
Course Home