Photo AI

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 icon

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-Scottish Highers Computing Science-Question 14-2023.png

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

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

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

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

Answer

  1. Missing SUM/TOTAL around the calculation {price * quantity}.
  2. Missing JOIN between OrderItem and Dish.
  3. Missing GROUP BY orderID.

Join the Scottish Highers students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;