DP Computer Science · HL / SL · A3 Databases

A3.2 Database design

Get started
Notes Quiz
Free preview 2/15
  1. Question 1

    A school tuck shop stores all sales data in a single flat-file table: `SaleDraft(SaleID, StudentID, StudentName, StudentEmail, ItemCode, ItemName, ItemPrice, Quantity, SaleDate)`. A student changes their email address. What problem does this flat-file design cause, and what is the correct solution?
    No clue? Show me the answer
    Correct answerCorrect!Incorrect
    BAn update anomaly occurs — the email may be stored in multiple rows and updating only some creates inconsistency. The solution is to store student data in a separate Student table referenced by a foreign key.

    Step-by-step walkthrough

    Choose a solution method

    Method #1Approach 1

    Step 1: Identify the scenario

    A student's email appears in every row of the flat-file table for every item they have purchased. When the email changes, every one of those rows needs to be updated.

    Step 2: Apply the definition of update anomaly

    An update anomaly occurs when a single real-world change (one student's email) requires updates to multiple rows. If even one row is missed, the database contains contradictory data about the same student.

    Step 3: Apply the relational solution

    The fix is normalisation: move student data (StudentID, StudentName, StudentEmail) into its own Student table. The SaleDraft table retains StudentID as a foreign key, so each student's email is stored exactly once.

    Step 4: Select the correct answer

    The answer that correctly names the update anomaly and proposes a separate Student table with a foreign key is the correct choice.

    Method #2Approach 2

    Step 1: Identify what is being asked

    The question asks which database anomaly is caused by changing an email stored in a flat-file table, and what the correct fix is.

    Step 2: Eliminate 'No problem occurs'

    'No problem occurs because SaleID uniquely identifies each sale row' is incorrect. SaleID makes rows unique but does not prevent the same email from appearing in many rows — the anomaly still exists.

    Step 3: Eliminate the deletion anomaly option

    'A deletion anomaly occurs — deleting the student record removes all sale records' describes a real anomaly type, but it is not triggered by changing an email. Deletion anomalies arise when removing a record, not updating one.

    Step 4: Eliminate the insertion anomaly option

    'An insertion anomaly occurs — the email cannot be stored until a sale is made' is also a real anomaly, but again it describes adding new data, not modifying existing data. The scenario specifically involves updating an email.

    Step 5: Select the correct answer

    The remaining option correctly identifies this as an update anomaly and provides the correct solution: a separate Student table with a foreign key reference.

  2. Question 2

    An online bookshop database includes the following tables: `Customer(CustomerID, Name, Email)`, `Order(OrderID, CustomerID, OrderDate)`, `OrderLine(OrderID, BookID, Quantity)`, and `Book(BookID, Title, Price)`. The `OrderLine` table has a composite primary key of `(OrderID, BookID)`. Which statement about the `OrderLine` table is correct?
    No clue? Show me the answer
    Correct answerCorrect!Incorrect
    BThe composite key (OrderID, BookID) uniquely identifies each line item because the same book can appear in different orders and an order can contain multiple books.

    Step-by-step walkthrough

    Choose a solution method

    Method #1Approach 1

    Step 1: Recall the purpose of a composite primary key

    A composite primary key is used when no single column is sufficient to uniquely identify a row. It combines two or more columns whose values together are unique for every record.

    Step 2: Apply the concept to OrderLine

    In OrderLine, a single OrderID can appear many times (one row per book in the order). A single BookID can also appear many times (the same book purchased in many orders). Neither column is unique on its own.

    Step 3: Confirm the composite key works

    The combination (OrderID, BookID) is unique: a specific order can only contain any specific book once as a line item. This makes the combination a valid composite primary key.

    Step 4: Select the correct answer

    The option stating that (OrderID, BookID) is correct because the same book can appear in different orders and an order can have many books correctly explains why a composite key is needed.

    Method #2Approach 2

    Step 1: Identify what is being asked

    The question tests understanding of why a composite primary key is used in a junction/line-items table.

    Step 2: Eliminate 'OrderID alone is sufficient'

    'OrderID alone can uniquely identify every row' is incorrect. One order contains multiple books, so OrderID repeats for each book — it is not unique within OrderLine.

    Step 3: Eliminate 'BookID should be the sole primary key'

    'BookID uniquely identifies each book' is true in the Book table, but in OrderLine, the same book can appear in many orders — BookID is not unique in this table.

    Step 4: Eliminate 'no primary key needed'

    'OrderLine does not need a primary key' violates entity integrity — every table must have a primary key. This option is incorrect on a fundamental design principle.

    Step 5: Select the correct answer

    The option explaining that (OrderID, BookID) together uniquely identify each line item is the only logically sound explanation.

Free preview

13 more questions in this topic

Next topic →A3.3 Database programming
Koncepts

Learn it properly. Then practise like it's the real paper.

Start free

Features

  • Lessons
  • Past papers
  • Library
  • Homework Help
  • Duels

More

  • For parents
  • Compare
  • Plans & pricing
  • DP for students

Legal

  • Privacy
  • Terms
  • Account deletion

© 2026 Koncepts (product of PrepAiro, Inc). All rights reserved.
DP, IB, EE and TOK are terms of the International Baccalaureate Organization.

Made for IB DP students.