Question 1
15 marks
Small shop customer database benefits, costs, primary/secondary keys, SQL queries, and query optimization
- Databases
(a)(i)
1 mark
- Identify one business benefit of implementing a customer database:
- Enables structured sales trend analysis, improved financial tracking, or faster retrieval of customer order histories.
Mentor tip
State any clear operational advantage such as improved financial control, sales analysis, or better customer service.
(a)(ii)
1 mark
- Identify one implementation cost:
- Staff training expenses, DBMS software licensing/maintenance costs, or hardware acquisition/upgrade expenses.
Mentor tip
Mention software, hardware, or personnel training costs.
(b)(i)
1 mark
- Count the columns (`Name`, `Date`, `ItemOrdered`, `QuantityOrdered`, `InvoiceAmount`) in `CustomerTable`:
- There are `5` fields in each record.
Mentor tip
Fields correspond to columns in a relational table.
(b)(ii)
2 marks
- Explain why `Name` is unsuitable as a primary key:
- 1. A primary key must uniquely identify every individual record in a table (no duplicate values).
- 2. Different customers can share the same name, or the same customer can place multiple orders—for instance, `Ann Low` appears twice in `CustomerTable` (on `18/04/2015` and `19/04/2015`).
Mentor tip
Cite the exact duplicate value from the table (`Ann Low`) to support why `Name` violates uniqueness.
(b)(iii)
1 mark
- Define a secondary key:
- An attribute (or set of attributes) that is not selected as the primary key, used as an index to speed up searching and sorting records (or a non-selected alternate key).
Mentor tip
Define a secondary key as a field indexed for faster searching/sorting or an alternate key not chosen as the primary key.
(c)
4 marks
- Construct the query steps or SQL statement to retrieve the target items:
- 1. Select the output column `ItemOrdered` from `CustomerTable`.
- 2. Filter rows where `Date` equals `'19/04/2015'`.
- 3. Filter rows where `QuantityOrdered` is strictly greater than `5` (`QuantityOrdered > 5`).
- 4. Combine both conditions using the logical `AND` operator:
- ```sql SELECT ItemOrdered FROM CustomerTable WHERE Date = '19/04/2015' AND QuantityOrdered > 5; ```
Mentor tip
Make sure all four elements are explicit: `SELECT ItemOrdered`, `Date = '19/04/2015'`, `QuantityOrdered > 5`, and the `AND` logical operator.
(d)
5 marks
- Explain software and structural optimizations to speed up query response time without changing hardware:
- 1. Normalize into a Relational Schema: Split the flat file into normalized relational tables (`Customers`, `Orders`, `Items`) to eliminate redundant data.
- 2. Faster Scanning: Smaller, non-redundant tables require fewer disk reads and less memory during query execution.
- 3. Create Indexes on Frequently Queried Fields: Add secondary key indexes on `Date` and `ItemOrdered` so the DBMS uses fast tree lookups rather than full-table linear scans.
- 4. Disk Defragmentation / Compaction: Defragment the storage drive and compact the database file so related table blocks are stored contiguously, minimizing disk head seek times.
- 5. Archive Historical Records: Move old completed orders out of the active operational table to keep the working dataset small.
Mentor tip
Link each software action (normalizing tables, adding indexes, defragmenting storage) to why it speeds up queries (reduced redundancy, fewer disk seeks, smaller search space).

