IFB105 Practice Exam — Fully Worked Solutions

Every question from the official practice exam, with the answer and the reasoning so you can reproduce it. Try each yourself first, then check.


SECTION A — Multiple choice (15 × 1 mark)

Q1 — Which is an elementary fact? → (c) An elementary fact is atomic, asserts something true, and has no conditions.

Q2 — Value type object in "Student N2345 received Grade 5 in Unit ABC123"? → (a) Grade A value type has no reference mode. StudentID/UnitCode are reference modes; Unit is an entity type; "ABC123" is a data value. Grade is the value type object.

Q3 — Arity of "Hotel Room 1123 is vacant"? → (a) Unary Only one object (Hotel Room) playing one role (is vacant/occupied) → unary.

Q4 — One-to-one association? → (d)

Q5 — Which diagram is incorrect? → (b) The n–1 rule: a uniqueness constraint must span at least (n–1) roles of an n-ary fact type. Option B's UC placement breaks this rule, so it's the invalid diagram.

Q6 — True statement about the hospital ORM? → (a)

Q7 — Correct RMap? → (d)

Q8 — "Every super key is a candidate key, but not every candidate key is a super key." → (b) False It's the reverse: every candidate key is a super key, but not every super key is a candidate key (some super keys are reducible).

Q9 — Highest normal form of the Store/Product table? → (b) 1NF Atomic + composite key (StoreID, ProductID) → 1NF. But ManagerID & ManagerName depend on StoreID alone (part of the key) → partial dependency → fails 2NF. Highest = 1NF.

Q10 — Book table normalised to 3NF? → (a) LoanedTo is optional (nulls present) → [LoanedTo], eliminating (b),(c). AuthorID is mandatory, eliminating (d). A book has multiple authors → m:n needs a bridge table:

Book {BookID, BookTitle, [LoanedTo]}
Author {AuthorID, AuthorName}
Authorship {BookID, AuthorID}

Q11 — True statement (PK = PatientID, DoctorID)? → (d) P1214 appears twice with different WardNames → WardName is NOT dependent on PatientID (kills a,b,c). But the same PatientID always gives the same PatientName → PatientName depends on part of the PK (PatientID only) → partially dependent ✓.

Q12 — Candidate key? → (c) (PatientID, WardName) (DoctorID, WardName) duplicates; PatientID alone duplicates. (PatientID, WardName) is unique and irreducible (drop DoctorID from option d and it's still unique) → candidate key.

Q13 — "A primary key is used in the child table to reference the parent." → (b) False That describes a foreign key.

Q14 — What does the GROUP BY/COUNT query return? → (d) Groups loans by bookID and counts rows per book → how many times each bookID appears in the loans table.

Q15 — Correct UPDATE query? → (c)

UPDATE Customers SET Address = '19 Albert Street' WHERE CustomerID = 'CU091214';

ALTER changes structure; option B is missing UPDATE; MODIFY isn't valid SQL.


SECTION B — Short answer

Q16 — CARE principles for the AIBS scenario

Q17 — Number of objects per elementary fact

Q18 — CSDP Steps 1 & 2 for the Product table (a) One elementary fact per fact type (using PRO123512):

  1. The Product with ProductID "PRO123512" has the ProductName "Sunshine Farms Apple Juice".
  2. The Product with ProductID "PRO123512" has the Price $5.00.
  3. The Product with ProductID "PRO123512" has the Quantity 2L.
  4. The Product with ProductID "PRO123512" has the UnitPrice $2.50.

(b) Step 2 — fact types drawn (described, since you'll draw it):

Q19 — Constraint violations (ORM: Student currently-enrolled-in / has-completed Degree) Constraints: C1 = every Student must play "currently enrolled in" (mandatory); C2 = student number unique in "currently enrolled in" (a student is enrolled in one degree at a time); C3 = (student, course) combination unique in "has completed".

Query Result Why
Add CurrentlyEnrolledIn 00003 IN01 Executed 00003 not yet enrolled; no conflict.
Add CurrentlyEnrolledIn 00001 IF63 C2 Violated 00001 already plays "currently enrolled in" → uniqueness on student number breached.
Delete CurrentlyEnrolledIn 00001 IF49 C1 Violated Would leave 00001 (who has completed IN01) without a mandatory "currently enrolled in" role.
Add HasCompleted 00002 IF49 Executed 00002 is currently enrolled; new (student,course) combo.
Add HasCompleted 00003 IN01 C1 Violated 00003 isn't currently enrolled → can't play "has completed" without the mandatory role.
Add HasCompleted 00001 IN01 C3 Violated (00001, IN01) already exists in "has completed".

Q20 — RMap for the Device/Installation schema

Q21 — Normalise the Provider/Appointment table to 3NF (PK = ProviderID, AppointmentTime)

Provider    {providerID, providerName, role}
Appointment {providerID, appointmentTime, patientID}    FK providerID→Provider, FK patientID→Patient
Patient     {patientID, patientName}

Q22 — Fill in the CREATE TABLE blanks

Blank Answer
A PRIMARY KEY
B NOT NULL
C NOT NULL
D ENUM
E FOREIGN KEY
F REFERENCES
G FOREIGN KEY
H REFERENCES

Q23 — Will each INSERT execute or fail?

Query Result Why
INSERT INTO Customer VALUES (5,'Ivy','Lee','i.lee@email.com','0412121212') Fail email must be unique; i.lee@email.com already exists (customer 4).
INSERT INTO Ticket VALUES (15,2,3,'Child',NULL) Executed new ticketID, valid eventID & orderID, valid ENUM, seatNo nullable.
INSERT INTO Event VALUES (5,'Strawberry...','Cornetto Stadium',NULL,'Concert') Fail eventID 5 already exists → duplicate PK.
INSERT INTO Extras VALUES (5,6,'Popcorn',4,NULL) Fail orderID 6 doesn't exist in Orders → FK / referential integrity violation.
INSERT INTO Orders VALUES (5,1,66.00) Fail orderID 5 already exists → duplicate PK.

Q24 — Customers whose combined purchases > $100

SELECT firstName, lastName, email
FROM Customer
WHERE customerID IN (
    SELECT customerID FROM Orders
    GROUP BY customerID
    HAVING SUM(totalPrice) > 100
);

(Group orders by customer, sum totalPrice, keep those over 100, return their details.)

Q25 — What do these queries return?

  1. Nested IN: VIP tickets → orderID 4 → customer 1 → Holly Richardson.
  2. HAVING count(*)>2 gives orders {1,3,5}; totalPrice<100 gives {1,4,5}; EXCEPT removes {1,4,5} → 3.
  3. Extras orderIDs {2,5}; only order 5 has a 'Child' ticket → 5.
  4. LEFT JOIN where notes IS NULL AND quantity IS NOT NULL → only Extras row for order 5 (Popcorn, qty 2, no notes) → totalPrice of order 5 → 59.00.