Question 1
15 marks
Restaurant ordering database structure, date formats, composite keys, and SQL queries
- Databases
(a)
4 marks
- 1. Data integrity and normalization: A relational database enforces structural constraints and referential integrity across related tables, ensuring that customer and meal records remain consistent and free of redundant anomalies.
- 2. Concurrent multi-user access: A database management system supports record locking and transaction management so multiple restaurant staff members can enter orders and update stock simultaneously without corrupting shared files (unlike a flat spreadsheet loaded entirely into memory).
Mentor tip
Provide two distinct reasons, each paired with a clear expansion on how the database improves operations compared to a spreadsheet.
(b)
2 marks
- Storing dates in the ISO 8601 format (`yyyy/mm/dd`) ensures that chronological sorting matches alphabetical/lexicographical sorting (ordering by year first, then month, then day).
- It also facilitates seamless data integration and compatibility across international database systems without ambiguity between day-first and month-first conventions.
Mentor tip
Highlight how year-month-day order allows standard string or numeric sorting to naturally place dates in true chronological sequence.
(c)
3 marks
- Combining `OrderID` and `ItemID` forms a natural composite key because each distinct meal item appears at most once per customer order (with `Quantity` tracking multiple portions).
- Using existing foreign keys eliminates the need to generate and store an arbitrary surrogate `OrderlineID` column, saving disk space and avoiding a meaningless attribute that would never be searched directly.
Mentor tip
Explain both why the pair is unique per order line and how omitting a separate surrogate key saves storage.
(d)
2 marks
- When joining `ORDERLINE` and `ITEM` in a query, referencing `UnitPrice` without a table prefix creates an ambiguous column name conflict.
- The query parser will fail to execute and return a syntax/ambiguity error unless the attribute is explicitly qualified using dot notation (such as `ORDERLINE.UnitPrice` or `ITEM.UnitPrice`).
Mentor tip
Mention column name ambiguity during multi-table queries and the requirement to qualify field names with their table names.
(e)
4 marks
- 1. Specify the required output columns: `CUSTOMER.FirstName`, `CUSTOMER.Surname`, and `ORDER.OrderDate`.
- 2. Identify the source tables: `CUSTOMER` and `ORDER`.
- 3. Join the tables on their common key: `CUSTOMER.CustomerID = ORDER.CustomerID`.
- 4. Filter the records using a `WHERE` clause matching both name fields:
- `SELECT CUSTOMER.FirstName, CUSTOMER.Surname, ORDER.OrderDate FROM CUSTOMER INNER JOIN ORDER ON CUSTOMER.CustomerID = ORDER.CustomerID WHERE CUSTOMER.FirstName = 'Akemi' AND CUSTOMER.Surname = 'Watene';`
Mentor tip
You can express the query steps either in SQL syntax or clear structured English, ensuring the join condition and both filter criteria are explicit.

