A takeaway restaurant is implementing an online ordering system and is using a relational database to store details about the dishes, customers, and orders - Scottish Highers Computing Science - Question 14 - 2023
Question 14
A takeaway restaurant is implementing an online ordering system and is using a relational database to store details about the dishes, customers, and orders.
The res... show full transcript
Worked Solution & Example Answer:A takeaway restaurant is implementing an online ordering system and is using a relational database to store details about the dishes, customers, and orders - Scottish Highers Computing Science - Question 14 - 2023
Step 1
Design a query to display the number of orders that the customer with custID 41 made in May 2023.
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To accomplish this, we will use the following SQL query:
SELECT COUNT(*)
FROM CustOrder
WHERE custID = 41
AND orderDate LIKE '%/05/2023';
Step 2
Complete the design of a query to display the full name and telephone number of every customer who has ordered a main dish.
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
To display the required information, the following SQL design should be applied:
Field(s) and Calculation(s): surname, forename, telephone
Tables(s): Customer, CustOrder, OrderItem, Dish
Search Criteria: course = 'Main'
Grouping: CustID
Sort Order: surname ASC
Step 3
Write the SQL statement that would implement this.
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The SQL statement to update the prices of main dishes containing chicken is:
UPDATE Dish
SET price = price + 2
WHERE course = 'Main' AND description LIKE '%chicken%';
Step 4
Identify three errors in the above SQL statement.
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Missing SUM/TOTAL around the calculation {price * quantity}.
Missing JOIN between OrderItem and Dish.
Missing GROUP BY orderID.
Join the Scottish Highers students using SimpleStudy...