Skip to content
Cambridge AS & A Level9618

Database Concepts

Computer Science 9618 Chapter Notes

Last updated November 2026

ShareWhatsAppPost

Database Concepts notes as a printable PDF.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Database Concepts notes as text: skim, search, and jump between subtopics.

~14 min read

1. File-based approach and the relational answer

A file-based approach has a list of limitations. It has more data redundancy, because the same data is stored many times. It has more data inconsistency, because duplicated data might be stored differently, or data updated in one place is not updated everywhere. It has program-data dependence, because any change to the structure of the data means the programs that access that data have to be rewritten.

It is also not easy to perform complex searches, because a new program has to be written each time. User views cannot easily be implemented, so there could be a lack of privacy.

A relational database addresses these. Linked tables mean that each data item is stored only once, which reduces redundancy, and data stored once only needs to be updated once. The data is separate from the software, so changes to the data do not require programs to be rewritten. Complex queries are easier to run, and different views let users see only specific aspects of the database.

Examiner insight

“Some candidates need to improve their understanding of what is meant by program-data dependence.” “Some candidates found it more challenging to then expand on their answer.”

Worked example 13 marks

Bobby tells Kim that a file-based approach is usually better than a relational database.

Explain why Bobby is incorrect.

  1. 1

    Flat-file has more data redundancy [1]

  2. 2

    ... because the same data is stored many times [1]

  3. 3

    There is program-data dependence with flat files, so any change to the structure of the data means the programs that access that data have to be rewritten [1]

2. Relational database terminology

An entity is an object about which data can be stored, such as a customer or a house. It is represented as a table. A record, or tuple, is a row of data in a table about one instance of an object. A field, or attribute, is a column in a table: an item of data about an entity.

A primary key is the unique attribute, or combination of attributes, used to identify the record. A candidate key is an attribute, or set of attributes, that could be a primary key. A secondary key is an additional or alternative key used as well as the primary key to locate specific data: a candidate key that has not been chosen as the primary key.

A foreign key is a field in one table that is linked to a primary key in another table. Referential integrity ensures that every foreign key has a corresponding primary key, so data that does not exist cannot be referenced.

Examiner insight

“An entity and a table are two different things.” “Some candidates need to understand when describing the primary key that it is the record that is uniquely identified and not the table.”

Worked example 13 marks

State what is meant by the following terms in a relational database model.

Entity

Primary key

Referential integrity

  1. 1

    Entity: an object about which data can be stored [1]

  2. 2

    Primary key: the unique attribute (or combination of attributes) used to identify the record [1]

  3. 3

    Referential integrity: ensures that every foreign key has a corresponding primary key, so data that does not exist cannot be referenced [1]

3. Relationships and E-R diagrams

A one-to-one relationship links one record to one record, for example a customer to their login details. A one-to-many relationship links one record to many, for example a customer to their orders. A many-to-many relationship links many to many, for example orders to products.

A many-to-many relationship cannot be directly implemented in a normalised relational database. It is replaced by a linking table that holds the primary keys of the two tables it links. Its primary key can be the composite of those two keys, or a new named key.

In a one-to-many relationship the primary key sits in the table on the one side and the foreign key in the table on the many side. One staff member can have many devices, so the primary key `StaffID` in `STAFF` links to the foreign key `StaffID` in `DEVICE`.

An entity-relationship (E-R) diagram documents the design. Each entity is a box, and lines join related entities, labelled with the relationship such as `1:M` between `CUSTOMER` and `SHOP_ORDER`.

Examiner insight

“The one-to-many relationship was more challenging.” “While there were some good answers to this question there were a few instances where the degree of the relationships was shown the wrong way round.”

Worked example 13 marks

Bobby has a shop that sells products to customers. His database will store data about his customers, their payment details, orders and the products he sells. Customers will have login details to access their accounts. The database will update customers' payment and login details without keeping any historical records.

Give one example of each of the following relationships from Bobby's database: one-to-one, one-to-many, many-to-many.

  1. 1

    one-to-one: customer to payment details, or customer to login details [1]

  2. 2

    one-to-many: customer to order [1]

  3. 3

    many-to-many: order to product [1]

4. Normalisation: 1NF, 2NF and 3NF

Normalisation takes a database that is not normalised (0NF) through three stages.

First Normal Form (1NF): there are no repeating groups of attributes, and the data is atomic. The stage from 0NF to 1NF removes any repeating groups of attributes.

Second Normal Form (2NF): all attributes are fully dependent on the (composite) primary key, with no partial key dependencies. The stage from 1NF to 2NF removes any partial key dependencies.

Third Normal Form (3NF): all attributes are fully dependent on the primary key and on no other attributes, with no non-key dependencies (no transitive dependencies). The stage from 2NF to 3NF removes any non-key dependencies.

Examiner insight

“Applying this to the database given in the question proved to be more challenging. Many answers attempted full normalisation which was not required.”

Worked example 14 marks

The following database table is not normalised.

Explain how to modify the table to put it into First Normal Form (1NF).

StudentNameDateOfBirthTutorGroupSubjectSubjectCode
Yuwei Chen01/09/2004SMHEnglish, Maths, Computer ScienceEN, MA, CS
Claudia Raj23/02/2005JMBMaths, Physics, ArtMA, PY, AR
Aamil Akram24/01/2005KMBArt, Design, English languageAR, DE, EN
Areeba Faraz21/12/2004SMHEnglish language, Chemistry, DesignEN, CH, DE
  1. 1

    Identify the repeating groups of attributes [1]

  2. 2

    These are `Subject` and `SubjectCode` [1]

  3. 3

    Ensure each field is atomic: `StudentName` should be split into, for example, `FirstName` and `LastName` [1]

  4. 4

    Identify the primary key for the table [1]

5. Explaining why tables are, or are not, in 3NF

Apply each rule to the given tables and name the fields. First, there are no repeating groups of attributes. Second, there are no partial key dependencies. A partial dependency needs a composite key: a field depends on only part of it. Third, every field is fully dependent on the primary key and on no other fields.

A table fails 3NF when a non-key field depends on another non-key field. This is a non-key dependency.

A database in 3NF also has no many-to-many relationships. A many-to-many relationship is removed with a linking table.

Examiner insight

“This question also required application of knowledge to the given database.”

Worked example 12 marks

The database HOUSE_RENTALS has the following structure:

``` CUSTOMER(CustomerID, FirstName, LastName, DateOfBirth, Email) HOUSE(HouseID, HouseNumber, Road, Town, Bedrooms, Bathrooms) RENTAL(RentalID, CustomerID, HouseID, MonthlyCost, DepositPaid) ```

Identify whether the database HOUSE_RENTALS is in Third Normal Form (3NF) or not in 3NF. Justify your choice using one or more examples from the database HOUSE_RENTALS.

  1. 1

    In 3NF: all fields in all tables are fully dependent on the primary key and on no other fields [1]

  2. 2

    For example, all fields in the `CUSTOMER` table are fully dependent on `CustomerID` [1]

6. Producing a normalised design

Give each entity its own table, and give every table a primary key. Where tables are related, put the primary key of one table into the other as a foreign key. Every original field must end up in the correct table.

A many-to-many relationship becomes a linking table. For example, a garden database with owners and trees can use a table that holds `OwnerID`, `TreeID` and `TreePosition`, with `OwnerID` and `TreeID` as its composite primary key.

When the question says underline the primary key fields, underline them in every table, including each field of a composite key.

Examiner insight

“Many candidates who gave the correct tables gave an incorrect primary key for the booking table because the start date was not included.” “Some candidates did not remove the car attributes from the booking table into a separate table and instead implemented a CUSTOMER_BOOKING table which led to confusion.”

Worked example 14 marks

The car rental database is not normalised. The current database design is:

``` BOOKING(CarRegistration, StartDate, EndDate, CarModel, CarColour, CustomerFirstName) CUSTOMER(CustomerFirstName, CustomerLastName, EmailAddress, TelephoneNumber) ```

Write a normalised database design for this database. All tables must be in Third Normal Form (3NF). Use the field names given and underline the primary key fields.

  1. 1

    Only three tables with appropriate identifiers: one for customer, one for booking and one for car [1]

  2. 2

    An appropriate primary key in each table, underlined [1]

  3. 3

    The `BOOKING` table includes the primary key from `CAR` and the primary key from `CUSTOMER` as foreign keys [1]

  4. 4

    All the original fields are in the correct tables [1]

  5. 5

    Example answer, primary keys marked PK:

  6. 6

    ``` BOOKING(BookingID PK, CarRegistration, CustomerID, StartDate, EndDate) CAR(CarRegistration PK, CarModel, CarColour) CUSTOMER(CustomerID PK, CustomerFirstName, CustomerLastName, EmailAddress, TelephoneNumber) ```

Recap

  • File-based limits: data redundancy, data inconsistency, program-data dependence, hard complex searches, weak privacy.
  • Relational fixes: each item stored once in linked tables, program-data independence, easy complex queries, views.
  • Entity = object data is stored about. Tuple = row. Attribute = column. Primary key identifies each record.
  • Candidate key could be the primary key; secondary key is a candidate key not chosen; foreign key links to a primary key in another table.
  • Many-to-many cannot be directly implemented: use a linking table.
  • 1NF: no repeating groups, atomic fields. 2NF: no partial dependencies. 3NF: no non-key dependencies.
  • Justify 3NF with the real field names, never a generic recital.

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. State what is meant by a primary key.1 mark
    Answer
    1. An attribute, or combination of attributes, that uniquely identifies each record in a table [1].

    Trap: Saying it identifies the table, when it identifies each record.

  2. A school keeps all its data in one file. A student's address is typed again for every club they join. Name the limitation this causes, describe one problem it leads to, and explain how a relational database avoids it.3 marks
    Answer
    1. Data redundancy: the same data is stored many times [1].
    2. Data inconsistency: when the address is updated in one place it is not updated everywhere, so the copies differ [1].
    3. Linked tables store the address only once, for example in a `STUDENT` table, so it only needs to be updated once [1].

    Trap: Naming the limitation with no expansion, when each point needs its consequence.

  3. A library database has the tables `BOOK(BookID, Title, Author)` and `LOAN(LoanID, BookID, DateDue, MemberName)`. Identify the foreign key in `LOAN` and explain your choice.2 marks
    Answer
    1. `BookID` is the foreign key [1].
    2. It is a field in `LOAN` that is linked to the primary key `BookID` in `BOOK` [1].

    Trap: Choosing `LoanID` because it is the first field, or defining a foreign key without saying it links to a primary key.

  4. One teacher teaches many classes, and each class has exactly one teacher. The tables are `TEACHER(TeacherID, Name)` and `CLASS(ClassID, Subject, TeacherID)`. State the relationship between `TEACHER` and `CLASS`, and name the foreign key.3 marks
    Answer
    1. One-to-many from `TEACHER` to `CLASS` [1].
    2. `TeacherID` in `CLASS` is the foreign key [1].
    3. It links to the primary key `TeacherID` in `TEACHER` [1].

    Trap: Reversing the relationship, or putting the foreign key in the table on the one side.

  5. In a school, a student can join many clubs and a club has many students. State the relationship. Explain why it cannot be directly implemented in a normalised relational database and say how the design is changed.3 marks
    Answer
    1. Many-to-many [1].
    2. Storing it directly would need a repeating group of club IDs in each student record, so the table would not be in 1NF [1].
    3. Add a linking table, for example `MEMBERSHIP(StudentID, ClubID)`, with both fields as foreign keys and together the composite primary key [1].

    Trap: Storing a list of club IDs in each student record, which is a repeating group of attributes.

  6. The table `PUPIL(PupilID, Name, Hobbies)` stores the text `Chess, Tennis` in the `Hobbies` field of one record. Explain why the table is not in First Normal Form and how to change it.2 marks
    Answer
    1. `Hobbies` holds more than one value, so it is a repeating group and not atomic [1].
    2. Store each hobby as its own record, for example in a new table `PUPIL_HOBBY(PupilID, Hobby)` [1].

    Trap: Attempting full normalisation to 3NF when only 1NF was asked for.

  7. `ORDER_LINE(OrderID, ProductID, Quantity, ProductName)` has the composite primary key `OrderID` and `ProductID`. Each field holds one value. `ProductName` depends only on `ProductID`. State the highest Normal Form of the table and justify your answer.3 marks
    Answer
    1. `ProductName` depends on only part of the key, `ProductID` [1].
    2. This is a partial dependency, so the table is not in 2NF [1].
    3. There are no repeating groups, so the highest Normal Form is 1NF [1].

    Trap: Calling the table 2NF because each field holds one value, when `ProductName` depends on only part of the composite key.

  8. A table is `EMPLOYEE(EmployeeID, Name, DepartmentID, DepartmentName)`. `EmployeeID` is the primary key. Each `DepartmentID` has one `DepartmentName`. Explain why the table is not in 3NF and show how to correct it.3 marks
    Answer
    1. `DepartmentName` depends on `DepartmentID`, which is a non-key field [1].
    2. This non-key (transitive) dependency means the table is not in 3NF [1].
    3. `EMPLOYEE(EmployeeID, Name, DepartmentID)` and `DEPARTMENT(DepartmentID, DepartmentName)`, with `DepartmentID` a foreign key in `EMPLOYEE` [1].

    Trap: Writing a generic list of the 3NF rules with no field names from the given table.

  9. A bike-hire company stores every hire in one table: ``` HIRE(HireID, BikeID, BikeType, Rate, MemberID, MemberName) ``` `HireID` is the primary key. Each bike is of one type, and every bike of the same type has the same hourly `Rate`. A member can make many hires. Explain why `HIRE` is not in 3NF and write a normalised design. Mark each primary key PK.6 marks
    Answer
    1. `BikeType` depends on `BikeID` and `MemberName` depends on `MemberID`, both non-key fields: non-key dependencies [1].
    2. `Rate` depends on `BikeType`, not on `BikeID`, so it needs a table of its own [1].
    3. `MEMBER(MemberID PK, MemberName)` [1].
    4. `BIKE(BikeID PK, BikeType)`, with `BikeType` a foreign key [1].
    5. `BIKE_TYPE(BikeType PK, Rate)` [1].
    6. `HIRE(HireID PK, BikeID, MemberID)`, with `BikeID` and `MemberID` foreign keys [1].

    Trap: Moving the bike fields out as `BIKE(BikeID, BikeType, Rate)`, which leaves a non-key dependency in the new table.

  10. A zoo stores feeding records in one table: ``` FEEDING(KeeperID, KeeperName, AnimalID, AnimalName, SpeciesName, SpeciesDiet, FeedDate, Amount) ``` The primary key is `KeeperID`, `AnimalID` and `FeedDate`. A keeper feeds many animals and an animal is fed by many keepers. Each animal belongs to one species, and `SpeciesDiet` depends only on `SpeciesName`. (a) State the relationship between keepers and animals. (b) Explain why `FEEDING` is not in 3NF and write a normalised design.8 marks
    Answer
    1. (a)
    2. Many-to-many [1].
    3. (b)
    4. `KeeperName` depends only on `KeeperID`, and `AnimalName` and `SpeciesName` only on `AnimalID`: partial dependencies [1].
    5. `SpeciesDiet` depends on `SpeciesName`, a non-key field, so there is a non-key dependency [1].
    6. `KEEPER(KeeperID, KeeperName)` [1].
    7. `SPECIES(SpeciesName, SpeciesDiet)` [1].
    8. `ANIMAL(AnimalID, AnimalName, SpeciesName)` with `SpeciesName` as a foreign key [1].
    9. `FEEDING(KeeperID, AnimalID, FeedDate, Amount)`, a linking table with all three fields as the composite primary key [1].
    10. The design needs the foreign keys `KeeperID` and `AnimalID` in `FEEDING` to link the tables [1].

    Trap: Dropping `FeedDate` from the composite key of the linking table, so each keeper could feed an animal only once.

Say this, not that

Wording that loses the mark, against the wording the mark scheme credits.

Loses the markGets the mark
An entity is a table.An entity is an object about which data can be stored; a table holds the data about it.
The primary key identifies the table.The primary key uniquely identifies each record.
A tuple is a column.A tuple is a row of data about one instance of an object.
A foreign key is a key from another table.A foreign key is a field in one table that is linked to a primary key in another table.

Frequently asked questions

Is a file-based approach to storing data usually better than a relational database?
No. A file-based approach has more data redundancy, because the same data is stored many times, and more data inconsistency, because duplicated data might be stored differently. It also has program-data dependence, so a change to the structure of the data means the programs that access it have to be rewritten. Linked tables store each data item only once.
What is a foreign key?
A foreign key is a field in one table that is linked to a primary key in another table. The primary key uniquely identifies each record. Referential integrity ensures that every foreign key has a corresponding primary key, so data that does not exist cannot be referenced.
What is the difference between a one-to-many and a many-to-many relationship?
A one-to-many relationship links one record to many, for example a customer to their orders. A many-to-many relationship links many to many, for example orders to products. It cannot be directly implemented in a normalised relational database, so it is replaced by a linking table that holds the primary keys of the two tables it links.
What does an entity-relationship (E-R) diagram show?
An E-R diagram documents the design of a database. Each entity is a box, and lines join related entities, labelled with the relationship, such as 1:M between `CUSTOMER` and `SHOP_ORDER`. In a one-to-many relationship the primary key sits in the table on the one side and the foreign key in the table on the many side.
What do First, Second and Third Normal Form mean in normalisation?
First Normal Form has no repeating groups of attributes, and the data is atomic. Second Normal Form has no partial key dependencies. Third Normal Form has no non-key dependencies, so every attribute is fully dependent on the primary key and on no other attributes. Each rule must be applied to the field names of the given table.
Is it enough to give the general rules of 3NF to justify a table?
No. Many candidates correctly identified that a database was in 3NF, but justified it with generic statements about the requirements of 3NF without any application to the given tables. Apply each rule to the given tables and name the fields.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters