A2 (4)
A2 (4)
2024 – 2025
Assignment 2
Due: April 1st 23:59
———————————————————————————————————————
Overview
You have analyzed the requirements of the online printing ordering platform for digital printing firm
PIX Press in assignment 1. The company decided to remove some of the features so that they can
release the platform as soon as possible. Their developers have revised the E-R diagram and
produced a relational table schema with data type assigned. You are contracted to join them in
preparing the database for the system.
Tasks
Study the E-R diagram and the relational table schema. Construct the SQL statements for the
following tasks. Your answer should be executable in the departmental MySQL server, which is
running MySQL version 5.7.42.
1) [20%] Create the tables according to the constraints given, including all primary keys and foreign
keys. Columns that cannot be NULL must be set to NOT NULL. (Submission Requirement: Include
the exact CREATE TABLE statements in your answer.)
2) [20%] Write the SQL query for inserting the necessary data for the following order. (Submission
Requirement: Provide the SQL INSERT statements.)
Order ID 123
Customer David Brook (ID: 10060)
Birthday: November 20, 1989
Phone numbers: 960-0123, 550-1234
PIC Miranda Spears (ID: 9054)
Items Item 1
4x IMG_123.jpg (ID: 6)
from Gallery “Summer 2019” (ID: 7, created on Oct 22, 2019, owned by the
customer)
on product “4R glossy print” (ID: 3, @$1.1)
Status Printing in progress.
3) [60%] Load the data in A2_test_data.sql. For each of the following tasks, give a single SQL query
that provide the result needed. (Submission Requirement: Include the SQL query for each task and
execute the queries and submit a screenshot of the results.)
Select at least the primary key(s) of all related tables if the columns to be listed is not specified.
Assume ascending order if ordering direction is not specified.
Your query must handle all possible scenario according to the given constraint.
There should not be duplicated results.
A set of sample data is available on Moodle for your reference. You are suggested to test your
SQL with your own set of data.
Submissions
Submit your work in a single PDF file on Moodle before the deadline. Late penalty will be applied
for late submission.