DBAS6211 Ea
DBAS6211 Ea
• E.g., if your student number is 12345, and you are writing an examination for the
module PROG121, create a folder named 12345_Prog121_Exam and use this
throughout the session to save all of your files.
• Important: Upon completion of your assessment, you must save and close all your
open files and double click the ExamLog application on your desktop. You must follow
the instructions carefully to ensure that the information about the files that you have
submitted for this assessment has been logged on the network. Specify the location of
your source code on your question paper.
Draw an Entity Relationship Diagram (ERD) using Unified Modelling Language (UML) notation
according to the below business rules. Your design should be at the logical level – include primary
and foreign key fields and remember to remove any many-to-many relationships.
Business rules for a restaurant chain with several restaurants around the country:
A lot of data about restaurant staff employment has already been collected in a spreadsheet (an
extract from the spreadsheet is shown below). The data has been normalised to first normal form
already – underlined column names indicate composite primary key columns.
Note: A waiter can work at a specific restaurant only once. But waiters are allowed to move to a
different restaurant in the chain. The employment type for a waiter never changes.
Normalise the above data to the third normal form (3NF). Show all steps and the final answer in
the form of dependency diagrams.
Using MySQL, create a single Structured Query Language (SQL) script that answers all the below
questions. Include comments to indicate which part of the script answers which question.
The script must execute correctly using MySQL to get full marks.
Table: Restaurant
Data Data Field
Field name Req? Description Example
type format size
RestaurantID int Yes Autonumber 1
{PK} primary key
Name varchar(100) 100 Yes The name of the Bears of
restaurant Brooklyn
Occupancy int Yes Number of people 50
allowed in the
restaurant
Table: City
Data Data Field
Field name Req? Description Example
type format size
CityID {PK} int Yes Autonumber 2
primary key
Name varchar(100) 100 Yes The name of the Cape Town
city.
Table: RestaurantCity
Data Data Field
Field name Req? Description Example
type format size
RestaurantCityID int Yes Autonumber 14
{PK} primary key
RestaurantID int Yes Foreign key that 2
{FK1} links to the
Restaurant table
CityID {FK2} int Yes Foreign key that 1
links to the City
table
Table: City
CityID Name
1 Pretoria
2 Cape Town (7)
Table: RestaurantCity
RestaurantCityID RestaurantID CityID OpenDate CloseDate
1 1 1 2020-01-01
2 2 2 2022-01-01 2022-02-03
Q.3.3 Query the names of all the restaurants in the databases, sorted from highest
occupancy to lowest occupancy. Include all columns from the restaurant table. (2)
Q.3.4 Query the restaurants that closed between 2022-01-01 and 2022-12-31, both
inclusive. Include the CityID, OpenDate and CloseDate in the results. (5)
Q.3.5 Query the number of restaurants in each city. Include the CityID and the number of
restaurants in the results. (5)
Q.3.6 Query a list of all the restaurants in the database. Include the name of the
restaurant, the name of the city where it is located, and the restaurant's occupancy
in the results. (8)
Q.3.7 A restaurant is currently open if it does not have a closing date and the opening
date is not in the future. Create a view that gets the list of restaurants that are
currently open. Include just the name of each open restaurant in the results. (8)
A restaurant wants to store recipe information in a NoSQL database. Write MongoDB interactive
shell commands to complete the tasks below. Then, copy and paste all the commands from the
shell into a single text file for submission.
The commands must execute correctly using the MongoDB shell to get full marks.
Q.4.4 Query all the recipes where the calories are less than or equal to 300. (4)
END OF PAPER