CBDB3403 Database
CBDB3403 Database
CBDB3403 Database
CBDB3403
DATABASE
The COVID-19 crisis saw a rise in the digital economy. People went to online
shopping for purchasing more frequently than ever before as they embraced social
withdrawal, and it has since taken on a bigger role in daily life. Digital information and
communication technologies, including computers and mobile devices, are used by online
stores to access and manage user, customer, product, supplier, cart, order, and payment data.
Database design for the online platform is needed for them to manage their business
activities. So, a database system is needed to manage all the information.
1
2.0 Entity, Attributes and Primary Key
There are seven entities have been discovered in this business activities process. Those can be
used to register as customer, log in as user to view the products they need to purchase from
supplier and add to carts for check out to make payments.
Entities Description
Customer Contain personal information about the customer who register as user.
User Use to identify user for log in to do online shopping.
Supplier Record the supplier information who supply the products.
Products Record the product information and price which register for online
shopping.
Carts Store the products information that user adds the products to the carts.
Orders Store the order information which have checked by User.
Payments Record the payment information.
2
3.0 ALL relationships, cardinality, and participation for each identified entity.
User
Relationship table Relationship type cardinality participation
Customer table One to one Exactly one Compulsory participation
Customer
Relationship table Relationship type cardinality participation
User table One to one Exactly one Compulsory participation
Products
Relationship table Relationship type cardinality participation
User table One to Many Zero, one or more Optional participation
Customer table One to Many Zero, one or more Optional participation
Supplier
Relationship table Relationship type cardinality participation
Products table One to Many Zero, one or more Optional participation
Carts
Relationship table Relationship type cardinality participation
User table One to Many Zero, one or more Optional participation
Products table Many to Many Zero, one or more Optional participation
Orders
Relationship table Relationship type cardinality participation
Cart Table One to Many Zero, one or more Optional participation
Payments
Relationship table Relationship type cardinality participation
Order Table One to One Exactly one Compulsory participation
3
4.0 Entity Relationships Diagram (ERD)
4
5.0 Relational Schema
5
6.0 Relations tables
Table 1
User
Key Attributes Data Types
Primary Key User_Id Short Text
Foreign Key Customer_Id Short Text
UserName Short Text
email Short Text
password Short Text
6
Table 2
Customer
Key Attributes Data Types
Primary Key Customer_Id Short Text
Name Short Text
IC Number
Gender Short Text
DateOfBirth Date
address Long Text
Postcode Number
City Short Text
State
Country Short Text
Tel Number
email Short Text
password Short Text
7
Table 3
Products
Key Attributes Data Types
Primary Key Products_Id Short Text
Product_Name Short Text
Category Short Text
Price Decimal
Quantity Number
Brand Short Text
Foreign Key Supplier_Id Short Text
Table 4
Supplier
Key Attributes Data Types
Primary Key Supplier_Id Short Text
Supplier_Name Short Text
Products_Quantity Number
Location Short Text
8
Table 5
Carts
Key Attributes Data Types
Primary Key Cart_Id Short Text
Foreign Key Customer_Id Short Text
Foreign Key Product_Id Short Text
Quantity Number
Add_at Date
Table 6
Orders
Key Attributes Data Types
Primary Key Order_Id Short Text
Foreign Key Cart_Id Short Text
Product_Name Short Text
Price Decimal
Quantity Number
Purchase_Date Date
9
Table 7
Payments
Key Attributes Data Types
Primary Key Payment_Id Short Text
Foreign Key Order_Id Short Text
Invoice_No Short Text
Total_Price Decimal
Purchase_Date Date
10
7.0 Sample Record for each relation table
Customer table
User table
Supplier table
Products table
Carts table
11
Orders table
Payments table
12
8.0 SQL QUERY
1. Simple Query
Result
13
2. Sorting result
Result
14
3. AGGREGATE FUNCTION
This query calculates the total of the price in each order by multi the Price with the quantity
of the products which order by the customers.
FROM Orders;
Result
15
4. Sub-queries
Display and retrieve Customer Id, Name, phone number, Email from table carts.
Result
16
5. Query to alter the existing tables
Result
17
18