Revision Notes
AQA A-Level Computer Science (7517): Relational Databases – Revision Notes
Condensed AQA 7517 section 4.10.2 recall: the relational database concept, attribute, primary key, composite primary key, foreign key and referential integrity.
- Subject
- Computer Science
- Level
- A LEVELS
- Topic
- Fundamentals of databases
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to AQA A Level Computer Science (7517), 2015-onwards. Official specification .
Syllabus page (what it covers and how it is assessed): AQA A Level Computer Science.
Syllabus points this page covers
7517
- 4.10.2 Relational databases
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (7517).
Condensed recall for 4.10.2 Relational databases, AQA A-Level Computer Science (7517): explain the concept of a relational database and define attribute, primary key, composite primary key and foreign key. The worked examples are in the relational databases study guide; questions are in the relational databases practice questions.
The concept
A relational database stores data in tables. Each table holds data about one kind of thing. Tables are linked by key values, so related data can be combined without storing any fact twice.
| Word | Also called | Meaning |
|---|---|---|
| Table | Relation | One entity’s data |
| Column | Attribute, field | One property, one value per record |
| Row | Record, tuple | One occurrence of the entity |
The four definitions to learn
| Term | Definition | Key points |
|---|---|---|
| Attribute | A named property of an entity, held as a column | One value per record |
| Primary key | An attribute whose value uniquely identifies each record in a table | Unique; never empty (null); stable; only one per table |
| Composite primary key | A primary key made of two or more attributes that together identify each record | Used when no single attribute is unique, often in link tables |
| Foreign key | An attribute in one table that is the primary key of another table | Creates the link; values can repeat; lives in the table that refers |
Spotting keys in a table
Teacher (TeacherID, Name, DepartmentID) and Department (DepartmentID, DepartmentName, Room)
- Primary keys: TeacherID, DepartmentID.
- Foreign key: DepartmentID in Teacher.
- To find a teacher’s room: Teacher, then DepartmentID, then Department.
Enrolment (StudentID, CourseID, Grade)
- StudentID repeats, CourseID repeats, so neither is unique alone.
- The pair is unique: composite primary key (StudentID, CourseID).
- Each part is also a foreign key.
Referential integrity
- Every foreign key value must match an existing primary key value in the table it refers to.
- The database refuses to add a record that refers to a missing record, or to delete a record that other records still refer to.
- It keeps the links valid.
Why a relational database?
- Less duplicated data: each fact stored once.
- Consistent: one place to update.
- Flexible queries: combine tables through keys.
- Integrity: key rules keep data valid.
- Access control: users can see only the tables they need.
Choosing a primary key
| Candidate | Good key? | Reason |
|---|---|---|
| Student number | Yes | Unique, stable, never empty |
| Surname | No | Different people share it; it can change |
| Date of birth | No | Not unique |
| Email address | Sometimes | Unique but can change |
| Auto-numbered ID | Yes | Unique and stable |
Question styles to expect
- Define a term: give the key idea and what makes it distinct (for example, “unique” for a primary key, “primary key of another table” for a foreign key).
- Identify keys in given tables: name the attribute, the table it is in and, for a foreign key, the table it refers to.
- Explain why a composite key is needed: show that each attribute repeats on its own but the pair does not.
- Follow a link: start from a value in one table, read the foreign key, and find the matching record in the other table.
- Explain a benefit of linked tables: less repeated data, one place to update, flexible queries.
- Referential integrity: give an example of a record that would be refused, using values from the question.
Key terms
| Term | Definition |
|---|---|
| Relation | Another name for a table in a relational database |
| Record | A row; one occurrence of the entity |
| Field | A column; one attribute |
| Null | A missing or empty value |
| Referential integrity | The rule that every foreign key value must match an existing primary key value |
| Redundancy | The same data stored more than once |
| DBMS | Database management system: software that stores and queries the database |
| Link table | A table that connects two others, often with a composite primary key |
Exam traps
- Primary key means unique identification, not “first column”.
- Foreign keys can repeat; primary keys cannot.
- A composite key is one key with several attributes.
- The foreign key is in the table that refers to the other table.
- Surnames and dates are poor keys.
- Attribute is a column, record is a row.
- Refer to the data in the table when asked to identify keys.
Self-test
- Define an attribute.
- Define a primary key.
- Can a primary key be empty?
- Define a composite primary key.
- Why might a link table need a composite primary key?
- Define a foreign key.
- Can a foreign key value appear more than once in its table?
- What is referential integrity?
- Why is Surname a poor primary key?
- Give one benefit of storing data in linked tables instead of one large table.
- In
Pet (PetID, Name, OwnerID)which attribute is the foreign key? - What is the difference between a record and an attribute?
Answers
- A named property of an entity, stored as a column.
- An attribute whose value uniquely identifies each record in a table.
- No, it must never be empty (null).
- A primary key made of two or more attributes which together identify each record.
- Neither of the linked attributes is unique alone, but the pair is.
- An attribute in one table that is the primary key of another table.
- Yes.
- Every foreign key value must match an existing primary key value in the table it refers to.
- Different people can share a surname, and it can change.
- Any one of: less duplication; easier to keep consistent; flexible queries.
- OwnerID.
- A record is a row (one occurrence of the entity); an attribute is a column (one property).
More resources on this topic
Related resources
-
Study guides
AQA A-Level Computer Science (7517): Structured Query Language (SQL)
Deeper guide to AQA 7517 section 4.10.4: SQL to retrieve, update, insert and delete data from multiple tables and to define a table, with checked worked queries.
Computer Science · AQA · A Level
Read guide -
Practice questions
AQA A-Level Computer Science (7517): Structured Query Language (SQL) – Practice Questions
Original AQA 7517 section 4.10.4 questions with answers: writing SQL to retrieve, insert, update and delete data from several tables and to define a table.
Computer Science · AQA · A Level
Try questions -
Revision notes
AQA A-Level Computer Science (7517): Structured Query Language (SQL) – Revision Notes
Condensed AQA 7517 section 4.10.4 recall: SELECT, joins, aggregates, GROUP BY, HAVING, INSERT, UPDATE, DELETE and CREATE TABLE, with common errors.
Computer Science · AQA · A Level
Revise topic
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.