0% found this document useful (0 votes)
145 views

ITS62904 Practical Test MARCH2023

The document provides instructions for a practical test assessment worth 20% for a Database Systems module. It consists of 2 questions. Question 1 asks students to design an ERD based on requirements for an e-shop sale, identifying entities, attributes, relationships and keys. Question 2 provides a relational schema and asks students to write SQL statements to identify foreign keys and display customer/merchant information based on purchase dates and totals.

Uploaded by

Jayden Ooi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views

ITS62904 Practical Test MARCH2023

The document provides instructions for a practical test assessment worth 20% for a Database Systems module. It consists of 2 questions. Question 1 asks students to design an ERD based on requirements for an e-shop sale, identifying entities, attributes, relationships and keys. Question 2 provides a relational schema and asks students to write SQL statements to identify foreign keys and display customer/merchant information based on purchase dates and totals.

Uploaded by

Jayden Ooi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SCHOOL OF COMPUTING AND IT

DEGREE PROGRAMMES
ASSESSMENT 2
PRACTICAL TEST
WEIGTHAGE 20%
MARCH 2023

MODULE NAME: DATABASE SYSTEMS


MODULE CODE: ITS62904
DURATION: 1 HR 30 MINS

STUDENT NAME: Ooi Xian Biao


STUDENT ID: 0363327

Instructions
1) This paper consists of questions worth 50 marks. There are 2 questions in total.

2) Draw the model in Draw.io and copy paste your diagram here in this answer
booklet.

3) Answer all questions in this answer booklet.

4) Once completed, save it with your name and submit in the submission link
provided in your Times. Any delay in submission will cause marks capped.

5) You don’t have to convert into PDF. Word document submission is sufficient.
Question 1 (30 marks)

The Go-Green e-shop would like to hold a sale. It encourages its users (customers and merchants)
to participate in the sale of items. You are required to design an ERD or EERD based on the given
requirements. Consider to identify the entities, week entities, relationships, primary key and
attributes for each entity and ensure to resolve relationships identified.

 A user in the system is either a merchant, or a customer, but not both. (2 marks)
 For every customer, the database records a unique id, name, city, credit card number. (3 marks)

 For each merchant, the database records a unique id, name, city, account number, and a phone
number list with arbitrary size. (3 marks)

 The e-Shop can distribute only up to 10 different products from each merchant. (2 marks)

 The same product cannot be sold by two different merchants via the e-Shop. (2 marks)

 Each product has a unique id, a description, and a price. (2 marks)

 A merchant may impose additional handling fees on an item. Each handing fee has a handling
rate and a description. Handling rate is unique within each item. Each handling fee is associated
with exactly one product, whereas many handling fees can be associated with the same item. (5
marks)

 A customer can make purchase orders through the e-Shop. Each purchase order has a purchase
id, time, and date. Each purchase order can consist of an arbitrary number of products. For each
product in a purchase order, the purchase quantity is recorded.
(5 marks)

We also make the following assumptions:


 Every merchant in the database sells at least one product. (2 marks)
 Every product must be sold by a merchant. (2 marks)
 Every purchase order must have at least one product. (2 marks)
Question 2 (20 marks)

Consider the relational schema given in Figure 1. Read the description, and write the SQL
statement to answer the questions.

Customer (id, name, city, credit card)


Merchant (id, name, city, account)
Merchant-Phone (id, phone)
Handling-Fee (product_id, handling_rate,
description)
Purchase (purchase_id, time, date, customer_id )
Product (product_id, description, price,
merchant_id)
Consist (purchase_id, product_id, quantity)
Figure 1: Product –Purchase tracking

a) Identify the foreign keys in this schema. (6 marks)


Merchant_Id,Customer_Id,Purchase_id
b) Display the customer’s id for all customer who have purchased product on “10/06/2019” or on
“11/06/2019”. (8 marks)
SELECT DISTINCT c.id AS Customer_Id
FROM Customer c
JOIN Purchase p ON c.Id = p.Customer_Id
WHERE p.date IN (‘10/06/2019’, ‘11/06/2019’)
c) For each merchant, display the id and total amount of money that its products cost
(disregarding handling fees), under the condition that the total amount is greater than 500. The
result should be ordered in descending order of the total amount. (6 marks)
SELECT m.id AS merchant_id, SUM(p.price * c.quantity) AS total_amount
FROM Merchant m
JOIN Product pr ON m.Id = pr.merchant_id
JOIN Consist c ON pr.product_id = c.product_id
JOIN ourchase pu ON c.purchase_id = pu.purchase_id
WHERE (SELECT SUM (pri.price* co.quantity)
FROM Product pri
JOIN Consist co ON pri.product_id = co.product_id
WHERE pri.merchant_id = m.id) > 500
GROUP BY m.id
ORDER BY total_amount DESC;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy