Computer Science (9618)
Primary key: Unique identifier for each record (e.g., StudentID) Foreign key: Field in one table linking to the primary key of another Entity-Relationship (ER) diagrams: Show relationships: one-to-one (1:1), one-to-many (1:M), many-to-many (M:M)
1NF: No repeating groups, atomic values 2NF: In 1NF + no partial dependencies (all non-key fields depend on whole primary key) 3NF: In 2NF + no transitive dependencies
SELECT name, grade FROM Students WHERE grade = 'A' ORDER BY name ASC INSERT INTO Students (name, grade) VALUES ('Ali', 'A') UPDATE Students SET grade = 'A*' WHERE id = 5 DELETE FROM Students WHERE id = 10 Aggregate functions: COUNT(*), SUM(marks), AVG(marks), MAX(marks) JOIN: SELECT s.name, c.title FROM Students s **INNER JOIN** Courses c ON s.course_id = c.id
Topic 3 of 3Cambridge A Levels
Databases & SQL
Relational databases, normalisation, and SQL queries
A database is an organised collection of related data. A relational database stores data in tables (relations) linked by keys.
Key concepts:
Normalisation reduces data redundancy:
SQL (Structured Query Language):
Key Points to Remember
- 1Primary key uniquely identifies records; foreign key links tables
- 2Normalisation: 1NF → 2NF → 3NF reduces redundancy
- 3SELECT-FROM-WHERE is the core SQL query pattern
- 4JOINs combine data from multiple tables
Pakistan Example
NADRA's Database — 220 Million Records, One Primary Key
Pakistan's NADRA manages the national CNIC database — over 220 million records. Each citizen has a unique 13-digit CNIC number (primary key). Related tables store biometrics, addresses, and family relationships linked by foreign keys. SQL queries help police verify identities in seconds.