Professional Documents
Culture Documents
ITS 232
Table of Contents
1. Project Overview 3
1.1 Organization Background 3
1.2 Current System Descriptions 4
1.3 Project Objectives 8
3. Database Declaration 14
3.1 Tables 14
4. SQL Statements 20
4.1 Simple SQL Queries 20
4.2 Retrieving Data from Multiple Tables 25
4.3 Scalar Functions and Arithmetic/ Column Functions and Grouping 30
4.4 Sub Queries / Maintaining Data 35
5. References 40
2|Page
FINAL PROJECT REPORT ITS 232
1. Project Overview
1.1 Organization Background
Pet Lovers Centre (PLC) is not only the largest online pet store in Malaysia, but also the
largest and only pet care retail chain in Southeast Asia. The Pet Lovers Centre group was
founded in 1973 and has its headquarters in Singapore. PLC continues to satisfy pet
owners and animals. This is due to the fact that shopping at Pet Lovers Centre is all about
value and continually improving deals. The Pet Lovers Centre provides customers with
the largest and most recent selection of products, along with prompt, friendly, and helpful
service. The store sells over 15000 products from hundreds of pet care brands, allowing
all pet owners to purchase all pet supplies. The Pet Lovers Centre, therefore, provides the
best shopping experience ever.
3|Page
FINAL PROJECT REPORT ITS 232
Pet Lovers Centre (PLC) is a pet shop that sells over 15000 products across hundreds of pet care
brands. Every pet owner can buy all pet supplies to take care of their pets. To exceed customers'
expectations and provide exceptional service, the shop develops one database with the following
business operations:
Staff can serve many customers. Staff personal details such as staff ID, name, contact, address,
hired date will be recorded when recruiting new employees. Many employees can organize many
products. Customers can buy many products. Each product purchase will record the product ID,
name, price, category, manufactured date, and supplier ID. A staff member can sell many
products. Customers can make an order through a stall or online platform. When customers make
an order at the stall or online platform, customer personal details such as customer ID, name,
contact, address, order dat,e and pet ID will be recorded. All the products purchased by customers
viaonline platform will be delivered to the customers’ address. A supplier will supply many
products for the shop. Each supplier will record suppliers’ personal details such as supplier ID,
name, contact, company name, address and product ID. The specifics of the products will be
documented such as product ID, name, price, category, manufactured, date and supplier ID.
Many products will be stored in many storages.
4|Page
FINAL PROJECT REPORT ITS 232
5|Page
FINAL PROJECT REPORT ITS 232
6|Page
FINAL PROJECT REPORT ITS 232
7|Page
FINAL PROJECT REPORT ITS 232
iii) To bring you the latest product, also ensuring you get what customer needs.
8|Page
FINAL PROJECT REPORT ITS 232
1 M
STAFF CUSTOMER
SERVE
M N
CUSTOMER PRODUCT
GET
9|Page
FINAL PROJECT REPORT ITS 232
1 M
PRODUCT SUPPLIER
PROVIDE
D
1 M
CUSTOMER PET
GRAB
10 | P a g e
FINAL PROJECT REPORT ITS 232
grab provided
STAFF
PK StaffID
StaffName
StaffAddress
StaffContact
PET
StaffHiredDate
PK PetID SUPPLIER
FK CustID PK SupplierID
PetName
FK ProductID
PetGender
SupplierContact
PetDOB
SupplierCompany
PetType
SupplierAddress
No. of Tables = 6
11 | P a g e
FINAL PROJECT REPORT ITS 232
11 | P a g e
FINAL PROJECT REPORT ITS 232
12 | P a g e
FINAL PROJECT REPORT ITS 232
13 | P a g e
FINAL PROJECT REPORT ITS 232
3. Database Declaration
3.1 Tables
1. Table: STAFF
StaffName VARCHAR(30),
StaffContact VARCHAR(15),
StaffAddress VARCHAR(100),
StaffHiredDate DATE,
Sample of output :
14 | P a g e
FINAL PROJECT REPORT ITS 232
2. Table: CUSTOMER
CustName VARCHAR(30),
CustContact VARCHAR(15),
CustAddress VARCHAR(80),
OrderDate DATE,
Sample of output :
15 | P a g e
FINAL PROJECT REPORT ITS 232
3. Table: PET
CustID VARCHAR(4),
PetName VARCHAR(10),
PetType VARCHAR(25),
PetGender VARCHAR(7),
PetDOB DATE,
Sample of output :
16 | P a g e
FINAL PROJECT REPORT ITS 232
4. Table: PRODUCT
ProductName VARCHAR(25),
ProductCategory VARCHAR(10),
ProductManufacturedDate DATE,
ProductPrice DECIMAL(6,2),
Sample of output :
17 | P a g e
FINAL PROJECT REPORT ITS 232
5. Table: SUPPLIER
SupplierCompany VARCHAR(30),
SupplierContact VARCHAR(15),
SupplierAddress VARCHAR(100),
Sample of output :
18 | P a g e
FINAL PROJECT REPORT ITS 232
6. Table: ORDER
OrderType VARCHAR(15),
Sample of output :
19 | P a g e
FINAL PROJECT REPORT ITS 232
4. SQL Statements
Query 1:
List each staff ID, staff name, staff contact number and staff address where the staff are
hired after 2020. Sequence the list by staff hired date descendingly.
20 | P a g e
FINAL PROJECT REPORT ITS 232
Query 2:
List product ID, product name, product category and product price where the product
price is greater than or equal to RM50. Sequence the list by product price ascendingly.
21 | P a g e
FINAL PROJECT REPORT ITS 232
Query 3:
List customer ID and order type where product ID is greater than ‘Y010’ and order type
is purchase order. Sequence the list by customer ID ascendingly.
22 | P a g e
FINAL PROJECT REPORT ITS 232
Query 4:
List supplier company, supplier contact number and supplier address where the supplier
ID is more than ‘X015’ or product ID is less than or equal to ‘Y005’. Order the list by
supplier ID descendingly.
23 | P a g e
FINAL PROJECT REPORT ITS 232
Query 5:
List the category of product available in the pet shop and order the list by product
category alphabetically.
24 | P a g e
FINAL PROJECT REPORT ITS 232
Query 1:
List staff ID and staff name for all customers. Sequence the list by staff ID.
25 | P a g e
FINAL PROJECT REPORT ITS 232
Query 2:
Identify manufacture date of product category food. Display the supplier ID, supplier
company, supplier contact, product category and product manufactured date. List by
supplier ID.
26 | P a g e
FINAL PROJECT REPORT ITS 232
Query 3:
Display supplier ID, supplier company, product name and product category. Order the
list by supplier ID in ascending order.
27 | P a g e
FINAL PROJECT REPORT ITS 232
` Query 4:
Identify the pet for all customers. Display customer ID, customer name, pet name, pet
type and pet date of birth.
28 | P a g e
FINAL PROJECT REPORT ITS 232
Query 5:
Identify all orders made by customers that show customer ID, product category and
order type. Order by order type descending.
29 | P a g e
FINAL PROJECT REPORT ITS 232
Query 1:
List the staff where the staff start working before 2022. Display the year and the month
of the hire date and staff id. Name the derived column YEAR and MONTH.
30 | P a g e
FINAL PROJECT REPORT ITS 232
Query 2:
The price of the product for product type medicine will decrease by RM20 for each. List
the product name, product id, product price and the decrese price for product. Use the
name LessProduct for the generated column.
31 | P a g e
FINAL PROJECT REPORT ITS 232
Query 3:
Calculate the total product price for all medicine products. Display the product
category and total price.
32 | P a g e
FINAL PROJECT REPORT ITS 232
Query 4:
Display the average for all products with an average below RM200. List the product
category and average.
33 | P a g e
FINAL PROJECT REPORT ITS 232
Query 5:
For all pets, count the number of pets owned by a customer.
34 | P a g e
FINAL PROJECT REPORT ITS 232
Query 1:
Find product name, category of product and the price of product that have
the lowest price.
35 | P a g e
FINAL PROJECT REPORT ITS 232
Query 2:
List customer name and customer contact number who own female pets only.
36 | P a g e
FINAL PROJECT REPORT ITS 232
Query 3:
List customer name, customer contact number and customer address where
the postcode is not ‘40150’ and order the list alphabetically.
37 | P a g e
FINAL PROJECT REPORT ITS 232
Query 4:
From table Product, find those product who got the second-highest price.
Return all the fields of the product.
SELECT *
FROM PRODUCT
WHERE ProductPrice = (SELECT ProductPrice
FROM PRODUCT
WHERE ProductPrice = (SELECT MAX(ProductPrice)
FROM PRODUCT
WHERE ProductPrice < (SELECT MAX(ProductPrice)
FROM PRODUCT)));
38 | P a g e
FINAL PROJECT REPORT ITS 232
Query 5:
Display PetID, CustID, PetName, PetType, and PetGenderwith the modified title
“Pet_Category” for the PetGender whose is ‘MALE’ and ‘FEMALE’. List all the
fields with the PetName in ascending order.
39 | P a g e
FINAL PROJECT REPORT ITS 232
5. References
1) Database System Concepts - 6th Edition.” Database System Concepts - 6th Edition, db-
book.com, 2016, https://db-book.com/db6/index.html.
2) Database System Concepts - 7th Edition.” Database System Concepts - 7th Edition, db-
book.com, 0 0 2017, https://db-book.com/.
3) ICT200.pdf. (2022). ebook - ICT200.pdf. Google Docs.
https://drive.google.com/file/d/1VRkIN1mCyhLvlfv6RCg1Ly9n_xQqset-/view
4) Notes and video lecture by Puan Suhanah Rosnan
5) Sql.Js Demo: Online SQL Interpreter.” Sql.Js Demo: Online SQL Interpreter, db-
book.com, 2022, https://db-book.com/university-lab-dir/sqljs.html.
40 | P a g e