Question 1
21 marks
Quick Rent-a-Car relational database keys, SQL queries, validation, views, DDL, and data consistency
- Databases
(a)(i)
1 mark
- State the relationship cardinality between CUSTOMER and RENTAL:
- One-to-many (1:M) — one customer can enter into multiple rental agreements over time.
Mentor tip
Look at the crow's foot symbol on the RENTAL side of the ERD link.
(a)(ii)
1 mark
- State the name of any one primary key from the schema:
- CustID (in CUSTOMER), RentalNum (in RENTAL), or CarID (in CAR).
Mentor tip
Any one of the three underlined/key identifiers (CustID, RentalNum, or CarID) is sufficient.
(a)(iii)
1 mark
- State the table that contains foreign keys:
- RENTAL (which holds CustID referencing CUSTOMER and CarID referencing CAR).
Mentor tip
The junction/transaction table at the 'many' end of both 1:M relationships holds the foreign keys.
(b)
1 mark
- Trace the SQL query against the CAR table (WHERE Man = "Lexus" AND Year = 2016):
- Row DHE7623 matches both Man = "Lexus" and Year = 2016; its Make attribute is:
- EF475
Mentor tip
Output only the projected Make value (EF475) rather than the entire record.
(c)
4 marks
- Check 1 — Format / Input Mask Check:
- 1) Verifies that CarID strictly follows the pattern of 3 uppercase letters followed by 4 digits (e.g. LLL0000 such as WRE2345).
- Check 2 — Length Check (or Presence/Uniqueness Check):
- 2) Verifies that the entered CarID string contains exactly 7 characters (not shorter or longer).
Mentor tip
Name two distinct validation checks (such as Format check LLL9999 and Length check = 7) and explain how each applies to CarID.
(d)
4 marks
- Identify the query steps to retrieve the customer's surname:
- 1) Select the target attribute: SELECT SName
- 2) Specify both required tables: FROM CUSTOMER INNER JOIN RENTAL
- 3) Join the tables on their shared key: ON CUSTOMER.CustID = RENTAL.CustID
- 4) Filter by the rental dates: WHERE DateOut = '22/01/2020' AND DateRet = '26/01/2020';
Mentor tip
Ensure you include the projection (SName), both table names, the join condition on CustID, and both date conditions.
(e)
3 marks
- Explain why queries are used to create database views:
- 1) Virtual Table Abstraction: A view encapsulates a complex multi-table join query into a reusable virtual table that staff can query simply without rewriting SQL.
- 2) Dynamic Updating: Because a view does not store separate physical data, it automatically reflects real-time changes made to the underlying CUSTOMER, RENTAL, and CAR tables.
- 3) Role-Based Security: Views can expose only specific non-sensitive columns or rows to front-desk employees while hiding restricted attributes in the base tables.
Mentor tip
Highlight that views act as virtual tables that simplify complex queries, stay dynamically updated, and restrict column/row visibility for security.
(f)
3 marks
- Explain how a Data Definition Language (DDL) implements the data model:
- 1) DDL commands (such as CREATE TABLE) define the database schema by creating the CUSTOMER, RENTAL, and CAR tables along with their field names and data types.
- 2) DDL specifies integrity constraints, including PRIMARY KEY declarations (CustID, RentalNum, CarID) and FOREIGN KEY relationships.
- 3) DDL statements (such as ALTER TABLE or DROP TABLE) allow the DBA to modify or maintain the table structure over time.
Mentor tip
Connect DDL to defining table structures, field data types, and primary/foreign key constraints.
(g)
3 marks
- Explain the importance of maintaining data consistency in the car rental database:
- 1) Referential and Transactional Accuracy: Consistency ensures that every record written to the database satisfies all defined constraints, cascades, and validation rules (e.g. a rental cannot reference a non-existent CarID or CustID).
- 2) Reliable Availability Tracking: Accurate, consistent state across tables prevents double-booking vehicles or charging customers for the wrong rental period.
- 3) Trustworthy Analytics and Compliance: Managers and external financial audits can rely on consistent data formats for reporting and decision-making.
Mentor tip
Link data consistency to enforcing integrity constraints, preventing booking conflicts, and ensuring reliable operational decisions.

