Professional Documents
Culture Documents
Prabin G.C.
Prabin G.C.
Prabin G.C.
Autumn 2023
I confirm that I understand my coursework needs to be submitted online via Google Classroom under the
relevant module page before the deadline in order for my assignment to be accepted and marked. I am
fully aware that late submissions will be treated as non-submission and a mark of zero will be awarded.
CC5051NI DATABASE
Table of Contents
1.Introduc+on ......................................................................................................................... 1
1.1 Aims and objec0ves of this Coursework. .................................................................................... 1
1.2Tools used in this Coursework. .................................................................................................... 1
1.3 Current Business Ac0vi0es and Opera0ons................................................................................ 3
1.4 Business Rule ............................................................................................................................. 3
1.5 Assump0ons .............................................................................................................................. 4
2. En+ty Rela+onship Diagram ................................................................................................ 4
2.1 ADributes and En0ty .................................................................................................................. 5
2.2 Crea0on of En00es and ADributes.............................................................................................. 5
3. Ini+al ERD ........................................................................................................................... 7
4.Normaliza+on ...................................................................................................................... 8
4.1 UNF (Un-Normalized Form) ........................................................................................................ 8
4.2 1NF (First Normal Form) ................................................................................................................................ 9
4.3 2NF (Second Normal Form) ......................................................................................................................... 10
4.4 3NF (Third Normal Form.............................................................................................................................. 11
Table of figures
Figure 1: Logo Of Ms-Word.............................................................................................................1
Figure 2:Logo of Draw.io. ................................................................................................................2
Figure 3: Example of SQL PLUS. ......................................................................................................2
Figure 4:IniRal ERD .........................................................................................................................7
Figure 5: Final Normalised ERD.....................................................................................................12
Figure 6: CreaRon of Customer table............................................................................................14
Figure 7:CreaRng Order table. ......................................................................................................16
Figure 8: CreaRng Invoice table. ...................................................................................................17
Figure 9: CreaRng table Product. ..................................................................................................19
Figure 10: CreaRng table Vendor. .................................................................................................20
Figure 11: CreaRng Customer_Order_Product table ....................................................................21
Figure 12: InserRng Values in Customer Table. .............................................................................23
Figure 13: SelecRng from Customer Table. ...................................................................................23
Figure 14: InserRng Values in Invoice Table. .................................................................................25
Figure 15: SelecRng from Invoice. ................................................................................................25
Figure 16:InserRng Values in Orders table. ...................................................................................27
Figure 17:SelecRng From Order table. ..........................................................................................27
Figure 18: INSERTING into Vendor table. ......................................................................................29
Figure 19: SelecRng from vendor. .................................................................................................29
Figure 20: INSERTING values in Product table. .............................................................................31
Figure 21: SelecRng From product................................................................................................31
Figure 22: INSERTING into customer_order_product table. .........................................................32
Figure 23: SelecRng from customer_order_product. ...................................................................33
Figure 24: List of customer which are also the staff of the company. ..........................................34
Figure 25: List of order between the given dates. ........................................................................34
Figure 26 : LisRng all the orders. ...................................................................................................35
Figure 27: LisRng the product which second le]er is 'a and stock level is >50. ............................35
Figure 28: Customer who ordered recently. .................................................................................36
CC5051NI DATABASE
Table of tables.
Table 1: EnRRes and A]ributes .......................................................................................................6
Table 2: Customer Table ader NormalizaRon. ..............................................................................13
Table 3: Order table ader NormalizaRon ......................................................................................15
Table 4: Invoice table ader normalizaRon. ...................................................................................17
Table 5: Product table ader normalizaRon. ..................................................................................18
Table 6: Vendor table ader normalizaRon. ...................................................................................19
Table 7: Customer_Order_Product table ader normalizaRon. .....................................................21
CC5051NI DATABASE
1.Introduc4on
For this individual coursework, we are required to design a database system for a “Gadget
Emporium”. Especially we are required to make a database system which can keep all the tracks
of all customers, products and orders which will help to create a strong database system to
support a business.
We can save necessary informaRon in this database which will include all the informaRon of the
customers and orders. All the data are safe and can be used at any Rme without any problems
which is all because of database.
In this Individual Coursework, A case study is provided for use to analyse and create a database
system that meets all the requirement for that insRtute.
Prabin G.C. 1
CC5051NI DATABASE
• Draw.io
Þ A proprietary tool for creaRng charts and diagrams is called draw.io. With the sodware,
you can design a bespoke layout or select from an automaRc layout feature. To create a
unique diagram or chart, they offer a vast array of shapes and hundreds of visual features.
Making an eye-catching diagram or chart is made easy with the drag-and-drop feature.
(Computer Hope, 2024)
Prabin G.C. 2
CC5051NI DATABASE
• Customers are categorized as Regular(R), Staff(S) and VIP(V) also the rate of
discount is also categorized according to customers categorization,
Prabin G.C. 3
CC5051NI DATABASE
• Invoice will include Destination, pickup location, Total price, and other information
about the Gadget.
1.5 Assump0ons
• The customers will be given a unique Customer_ID,
• One customer can order mulRple Rmes,
• Every single order has been assigned a unique Order_id.
Prabin G.C. 4
CC5051NI DATABASE
Þ A]ributes: An enRty's properRes are called a]ributes. Let's take another look at the
university management system example. The properRes of the student enRty are name,
residence, age, GPA, and student ID. The course enRty contains a]ributes including dur,
course name, and course id. (pedia, 2023)
• Product
Prabin G.C. 5
CC5051NI DATABASE
Prabin G.C. 6
CC5051NI DATABASE
3. Ini4al ERD
Prabin G.C. 7
CC5051NI DATABASE
4.Normaliza4on
NormalizaRon is the process of making the database more flexible by removing the varied
anomalies and data redundancies present in the database. NormalizaRon includes creaRng tables
and establishing relaRonships between those tables according to rules.
Prabin G.C. 8
CC5051NI DATABASE
Prabin G.C. 9
CC5051NI DATABASE
Customer_ID ® ´
Order_ID ® ´
From Customer_Order_Product 1
Customer_ID, Order_ID,Product_ID ® ´
Order_ID ® ´
Product_ID ® Product_Name, Product_Category, Unit_Price, Vendor_ID,
Vendor_Name, Vendor_Number, Stock_Level
Now, final table in 2NF:
Customer2 (Customer_ID(PK), Customer_Name, Customer_Address,
Customer_Number, Customer_Category, Discount_Rate)
Prabin G.C. 10
CC5051NI DATABASE
In summary, all these tables are in 2NF and is fully func@onally dependent on the
en@re primary key for each table.
From Order 2
Order_ID® Invoice_ID® Invoice_Date ® Payment_Op@on
From Product 2
Product_ID ® Vendor_ID ® Vendor_Name ® Vendor_Number
Final 3NF
Customer 3 (Customer_ID(PK), Customer_Name, Customer_Address,
Customer_Number, Customer_Category, Discount_Rate)
Prabin G.C. 11
CC5051NI DATABASE
5. Final ERD
Prabin G.C. 12
CC5051NI DATABASE
6. Data Implementa4on
The tables have been created by using ‘CREATE TABLE’ command. It is one of the most used
commands in MYSQL. To create a table using this command we need to provide a table name and
name of the columns that are going to be in the table. A table can have only one Primary Key and
a foreign key is a field in a table that refers to the primary Key in another table.
Prabin G.C. 13
CC5051NI DATABASE
Command
Create table Customer (
Customer_ID VARCHAR2 (20) Primary key,
Customer_Name VARCHAR2 (20) NOT NULL,
Customer_Address VARCHAR2 (20) NOT NULL,
Customer_Number Number (20,2) NOT NULL,
Customer_Category VARCHAR2 (20) NOT NULL,
Discount_Rate Number(9,2) NOT NULL);
Prabin G.C. 14
CC5051NI DATABASE
6.3 Orders
The Orders table ader NormalizaRon:
Prabin G.C. 15
CC5051NI DATABASE
Command
CREATE TABLE Orders (
Order_ID VARCHAR2(20) PRIMARY KEY,
Invoice_ID VARCHAR2(20) NOT NULL REFERENCES Invoice(Invoice_ID),
Customer_ID VARCHAR2(20) NOT NULL REFERENCES Customer(Customer_ID),
Order_Date DATE NOT NULL,
QuanRty INT NOT NULL,
Total_Amount NUMBER(9,2) NOT NULL);
Prabin G.C. 16
CC5051NI DATABASE
6.4 Invoice
A]ributes Data type Constraints DescripRon
Invoice_ID VARCHAR2(20) Primary Key This stores the
invoice id of the
customer.
Invoice_Date Date NOT NULL This stores the
invoice date of the
customer.
Payment_OpRon VARCHAR2(30) NOT NULL This field stores the
payment opRon.
Command
CREATE TABLE Invoice (
Invoice_ID VARCHAR2(20) Primary key,
Invoice_Date Date NOT NULL,
Payment_OpRon VARCHAR2(30) NOT NULL);
Prabin G.C. 17
CC5051NI DATABASE
6.5 Product
A]ributes Data type Constraints DescripRon
Product_ID VARCHAR2(20) Primary Key This stores the
product id of the
customer.
Vendor_ID VARCHAR2(20) Foreign Key, NOT This stores the
NULL Vendor_ID of the
customer.
Product_Name VARCHAR(255) NOT NULL This stores the name
of the product.
Product_Category VARCHAR(255) NOT NULL This field stores the
category of the
product.
Unit_Price Number(9,2) NOT NULL This field stores the
price of the products.
Stock_Level INT NOT NULL This field stores the
stock level of the
products.
Command
CREATE TABLE Product (
Product_ID VARCHAR2(20) Primary Key,
Vendor_ID VARCHAR2(20) NOT NULL,
Product_Name VARCHAR(255) NOT NULL,
Product_Category VARCHAR(255) NOT NULL,
Unit_Price DECIMAL(10,2) NOT NULL,
Stock_Level INT NOT NULL,
FOREIGN KEY (Vendor_ID) REFERENCES Vendor(Vendor_ID));
Prabin G.C. 18
CC5051NI DATABASE
6.6 Vendor
A]ributes Data type Constraints DescripRon
Vendor_ID VARCHAR2(20) Primary Key This stores the
vendor id.
Vendor_Name VARCHAR2(30) NOT NULL This stores the
vendor name.
Vendor_Number Number(20,2) NOT NULL This field stores the
vendor number.
Command
CREATE TABLE Vendor (
Vendor_ID VARCHAR2(20) Primary Key,
Vendor_Name VARCHAR2(30) NOT NULL,
Vendor_Number Number(20,2) NOT NULL);
Prabin G.C. 19
CC5051NI DATABASE
Prabin G.C. 20
CC5051NI DATABASE
Command
CREATE TABLE Customer_Order_Product(
Customer_ID VARCHAR(255) NOT NULL,
Order_ID VARCHAR(255)NOT NULL,
Product_ID VARCHAR(255) NOT NULL,
FOREIGN KEY (Customer_ID) REFERENCES Customer(Customer_ID),
FOREIGN KEY(Order_ID) REFERENCES Orders(Order_ID),
FOREIGN KEY(Product_ID) REFERENCES Product(Product_ID));
Prabin G.C. 21
CC5051NI DATABASE
Prabin G.C. 22
CC5051NI DATABASE
Prabin G.C. 23
CC5051NI DATABASE
Prabin G.C. 24
CC5051NI DATABASE
Prabin G.C. 25
CC5051NI DATABASE
Prabin G.C. 26
CC5051NI DATABASE
Prabin G.C. 27
CC5051NI DATABASE
Prabin G.C. 28
CC5051NI DATABASE
Prabin G.C. 29
CC5051NI DATABASE
Prabin G.C. 30
CC5051NI DATABASE
Prabin G.C. 31
CC5051NI DATABASE
Prabin G.C. 32
CC5051NI DATABASE
Prabin G.C. 33
CC5051NI DATABASE
8. Database Querying
8.1 Informa0on Query
8.1.1 List all the customers that are also staff of the company.
Command
SELECT *FROM Customer
WHERE Customer_Category = 'Staff';
Figure 24: List of customer which are also the staff of the company.
8.1.2 List all the orders made for any product between the dates 01-05-2023 Fll 28-05-2023.
Command
SELECT *
FROM Orders
WHERE Order_Date Between TO_DATE ('01-Jan-2023', 'DD-Mon-YYYY') AND
TO_DATE('28'-Jan-2023', 'DD-Mon-YYYY');
Prabin G.C. 34
CC5051NI DATABASE
8.1.3 List all the customers with their order details and the customers who haven’t ordered any
products yet.
Command
SELECT
C.Customer_ID, C.Customer_Name, O.Order_ID,O.Order_Date,O.Total_Amount,
O.Invoice_ID
FROM Customer C LEFT JOIN Orders O
ON C.Customer_ID = O.Customer_ID;
8.1.4 List all product details that have the second leIer ‘a’ in their product name and have stock
quanFty more than 50.
Command
SELECT *FROM Product
WHERE Product_name LIKE '_a%' AND Stock_Level > 50;
Figure 27: Lis+ng the product which second le/er is 'a and stock level is >50.
Prabin G.C. 35
CC5051NI DATABASE
8.1.5 Find out the customer who has ordered recently. DHFibernet@0414435
Command
SELECT Order_ID as Order_ID, customer_name
FROM Orders
JOIN customer ON Orders.customer_id = customer.customer_id
ORDER BY Order_date DESC
FETCH FIRST 1 ROWS ONLY;
Prabin G.C. 36
CC5051NI DATABASE
8.2.2 Find those orders that are equal or higher than the average order total value.
Command
SELECT *
FROM orders
WHERE Total_Amount >= (SELECT AVG(Total_amount) FROM orders);
Figure 30: The orders that are >= the average total amount.
Prabin G.C. 37
CC5051NI DATABASE
8.2.3 List the details of vendors who have supplied more than 3 products to the company.
Command
SELECT Vendor_id, Vendor_name
FROM Vendor
WHERE Vendor_ID IN (SELECT Vendor_id
FROM Product
GROUP BY Vendor_id HAVING COUNT(*) > 3);
Figure 31: Vendor who has supplied more than 3 products for the company.
Prabin G.C. 38
CC5051NI DATABASE
8.2.5 Find out the customer who has ordered the most in August with his/her total spending on
that month.
Command
SELECT*FROM (SELECT C.Customer_ID, C.Customer_Name,
SUM(O.Total_Amount) AS Spending_in_August FROM Customer C
JOIN Orders O ON C.Customer_ID = O.Customer_ID
WHERE TO_CHAR (O.Order_Date, 'MM-YYYY')= '08-2023'
GROUP BY C.Customer_ID, C.Customer_Name
ORDER BY Spending_in_August DESC)
WHERE ROWNUM = 1;
Prabin G.C. 39
CC5051NI DATABASE
9. Cri4cal Evalua4on
9.1 Further Discussion on your learning Experience.
At First, I did not have the knowledge about database but ader studying in this semester, I
have been able to design, develop and acquire knowledge about database and its design.
In this Semester, I have gained informaRon about how really the process of database runs and I
learned about different new topics like database querying and creaRng ERD.
NormalizaRon and ERD are the main topic to learn in this module in this semester. ERD is the
graphical representaRon of relaRonships of enRRes and their a]ributes. NormalizaRon is the
process in database system that helps to avoid the data redundancy. In this project I have done
normalizaRon in four steps UNF, 1NF, 2NF and 3NF. It also helped to learn SQL commands and
how to run SQL PLUS.
In the beginning, I was so much confused about where to start from and I didn’t have much
idea about database, due to this I had to face many problems while doing the coursework. That
made me to search a lot about database and its commands which really help me to gain more
knowledge and helped in doing coursework. I had problems while selecRng enRRes and in
normalizaRon. I carried various research to carry out this coursework. This coursework helped me
to understand more about database which will surely help me in my future.
Prabin G.C. 40
CC5051NI DATABASE
Prabin G.C. 41
CC5051NI DATABASE
Prabin G.C. 42
CC5051NI DATABASE
Prabin G.C. 43
CC5051NI DATABASE
Prabin G.C. 44
CC5051NI DATABASE
11.References
Byju's. (2022). From h]ps://byjus.com/govt-exams/microsod-
word/#:~:text=Used%20to%20make%20professional%2Dquality,in%20the%20best%20possible
%20way.
(2022). From Byjus.com: h]ps://byjus.com
(2019). From Tella: h]ps://www.tella.tv
(2024). From Computer Hope: h]ps://www.computerhope.com
Open Grass. (2023). From Open Grass: h]p://rdbms.opengrass.net/
pedia. (2023). From pedia: h]ps://pediaa.com/
Studytonight. (2023). From studytonight: h]ps://www.studytonight.com/
Geekforgeeks. (2023). From Geek For Geeks: h]ps://quillbot.com/
Prabin G.C. 45