customer_id in Reservation → references Customer.customerId
restaurant_id in Reservation → references Restaurant.restaurantId
Role in Referential Integrity: Ensures every reservation links to valid customers and restaurants, prevents orphaned records, enforces relationships, and enables cascade operations.
Keywords Found:
Q1210 marks
Explain First Normal Form (1NF) and describe violations that prevent a relation from being in 1NF.
✓ Model Answer
A relation is in 1NF if all attributes contain only atomic (indivisible) values.
Explain Second Normal Form (2NF) and the type of functional dependency that must be eliminated.
✓ Model Answer
A relation is in 2NF if it's in 1NF and every non-prime attribute is fully functionally dependent on the entire primary key.
Must eliminate: Partial dependencies (non-prime attributes depending on part of a composite key).
Keywords Found:
Q1410 marks
Explain Third Normal Form (3NF) and what must be eliminated to achieve it.
✓ Model Answer
A relation is in 3NF if it's in 2NF and no non-prime attribute is transitively dependent on the primary key.
Must eliminate: Transitive dependencies (A → B → C where B is non-prime).
Keywords Found:
💻 SQL Queries
20 marks
▼
Q1510 marks
Write a SQL query to find customers who have placed orders totaling more than $500.
Schema: Customers (CustomerID, Name), Orders (OrderID, CustomerID, TotalAmount)
✓ Model Answer
SELECT C.Name, SUM(O.TotalAmount) AS Total
FROM Customers C
JOIN Orders O ON C.CustomerID = O.CustomerID
GROUP BY C.CustomerID, C.Name
HAVING SUM(O.TotalAmount) > 500;
Keywords Found:
Q1610 marks
Write SQL queries to:
1. List all unique cities where customers live
2. Insert a new customer
3. Update a customer's address
✓ Model Answer
-- 1. Unique cities
SELECT DISTINCT City FROM Customers;
-- 2. Insert customer
INSERT INTO Customers (CustomerID, Name, City)
VALUES (101, 'John Doe', 'Riyadh');
-- 3. Update address
UPDATE Customers
SET Address = '123 Main St'
WHERE CustomerID = 101;