§1 Keys and relationshipsNote
Primary key: unique, non-null identifier of a row. Foreign key: references another table's key; enforces referential integrity. One-to-many is modelled with a foreign key on the 'many' side; many-to-many needs a junction table. §2 Normal formsForm Requirement 1NF Atomic values; no repeating groups 2NF 1NF + no partial dependency on part of a composite key 3NF 2NF + no transitive dependency (non-key → non-key)
§3 SQL you should be able to writeTask Statement Create CREATE TABLE item (id INT PRIMARY KEY, name VARCHAR(80), qty INT); Insert INSERT INTO item (id, name, qty) VALUES (1, 'Bond paper', 20); Read SELECT name, qty FROM item WHERE qty < 10 ORDER BY name; Update UPDATE item SET qty = qty - 1 WHERE id = 1; Delete DELETE FROM item WHERE id = 1; Aggregate SELECT category, COUNT(*) FROM item GROUP BY category;
§4 ACIDNote
Atomicity: all or nothing. Consistency: rules hold before and after. Isolation: concurrent transactions do not interfere. Durability: committed data survives failures. ! Common trapsWriting UPDATE or DELETE without WHERE. Using WHERE to filter aggregates — use HAVING.