Database Coursework Islington College
Database Coursework Islington College
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.
Acknowledgement
Acknowledgement ........................................................................................................... 2
1. Introduction .............................................................................................................. 1
1.1 Aims and Objectives .......................................................................................... 2
1.1.1 Aim .............................................................................................................. 2
1.1.2 Objectives .................................................................................................... 3
1.2 Current Business Activities and Operations ....................................................... 4
1.3 Business Rules .................................................................................................. 5
1.4 Assumptions....................................................................................................... 7
1.5 Identification of Entities and Attributes ............................................................... 8
1.5.1 Customer......................................................................................................... 8
1.5.2 Vendor ......................................................................................................... 9
1.5.3 Orders........................................................................................................ 10
1.5.4 Product ...................................................................................................... 11
2. Initial ERD .............................................................................................................. 12
2.1 Entity and Attributes ......................................................................................... 12
2.2 Initial Entity Relationship Diagram ....................................................................... 13
3. Normalization ......................................................................................................... 15
3.1. Un-Normalized Form (UNF) ................................................................................ 15
3.2 First Normal Form (1NF) .................................................................................. 17
3.3 Second Normal Form (2NF) ............................................................................. 19
3.4 Third Normal From (3NF) ................................................................................. 21
4. Final ERD ............................................................................................................... 24
5. Implementation....................................................................................................... 27
5.1 Creation of user................................................................................................ 27
5.2 Creating and Desribing the tables .................................................................... 28
5.2.1 Creating Customer table. .............................................................................. 28
5.2.2 Describing Customer table. ....................................................................... 29
5.2.3 Creating Vendor table ................................................................................ 30
5.2.4 Describing Vendor table ............................................................................ 31
5.2.5 Creating Payment table. ............................................................................ 32
5.2.6 Describing Payment table. ......................................................................... 33
5.2.7 Creating Product table. .............................................................................. 34
5.2.8 Describing Product table............................................................................ 35
5.2.9 Creating Orders table. ............................................................................... 36
5.2.10 Describing Orders table. ......................................................................... 37
5.2.11 Creating Order_Product table................................................................. 38
5.2.12 Describing Order_Product table ............................................................. 39
5.3 Data Insertion and Display Inserted Data. ........................................................ 40
5.3.1 Inserting values in Customer table. ............................................................... 40
5.3.2 Displaying all data of Customer table. ....................................................... 41
5.3.3 Inserting values in Vendor table. ............................................................... 42
5.3.4 Displaying all data of Vendor table. ........................................................... 43
5.3.5 Inserting values in Payment table. ............................................................. 44
5.3.6 Displaying all data of Payment table. ......................................................... 45
5.3.7 Inserting values in Product table. ............................................................... 46
5.3.8 Displaying all data of Product table. .......................................................... 47
5.3.9 Inserting values in Orders table. ................................................................ 48
5.3.10 Displaying all data of Orders table.......................................................... 49
5.3.11 Inserting values in Order_Product table. ................................................ 50
5.3.12 Displaying all data of Order_Product table. ............................................ 51
6. Database Querying ................................................................................................ 52
6.1 Information Query ............................................................................................ 52
6.2 Transaction Query ............................................................................................... 57
7. Critical Evaluation .................................................................................................. 62
7.1 Critical Evaluation of module, its usage and relation with other subject ........... 62
7.2 Critical Assessment of coursework .................................................................. 63
8. Database Dump File Creation ................................................................................ 64
9. Spool File Creation................................................................................................. 65
9.1 Spool File Creation of Information Query 1. ..................................................... 65
9.2 Spool File Creation of Information Query 2. ..................................................... 66
9.3 Spool File Creation of Information Query 3. ..................................................... 67
9.4 Spool File Creation of Information Query 4. ..................................................... 68
9.5 Spool File Creation of Information Query 5. ..................................................... 69
9.6 Spool File Creation of Transaction Query 1. .................................................... 70
9.7 Spool File Creation of Transaction Query 2. .................................................... 71
9.8 Spool File Creation of Transaction Query 3. .................................................... 72
9.9 Spool File Creation of Transaction Query 4. .................................................... 73
9.10 Spool File Creation of Transaction Query 5. ................................................. 74
10. Drop Query .......................................................................................................... 75
10.1 Dropping Order_Product Table. ......................................................................... 75
10.2 Dropping Product Table. .................................................................................... 75
10.3 Dropping Vendor Table. ..................................................................................... 76
10.4 Dropping Orders Table. ..................................................................................... 76
10.5 Dropping Payment Table. .................................................................................. 77
10.6 Dropping Customer Table. ................................................................................. 77
10.7 Showing that all Tables are dropped. ................................................................ 77
11. Conclusion........................................................................................................... 78
12. References .......................................................................................................... 79
Table of Figures
1. Introduction
The focus of "Gadget Emporium" lies in simplicity and efficiency. The proposed
system aims to simplify product management, categorize customers into Regular, Staff,
and VIP with corresponding discounts, facilitate smooth order processing, manage
vendor relationships, monitor real-time product availability, and offer diverse payment
options. The business rules highlight the emphasis on delivering a user-friendly
experience, where customers can easily browse, purchase, and enjoy the convenience
of secure payment methods.
1
CC5051NI Databases
1.1.1 Aim
The aim of implementing the database system for "Gadget Emporium" is to create a
robust platform that efficiently manages electronic gadgets and accessories. The
system will focus on key business rules, ensuring effortless product management,
customer categorization, order processing, vendor management, real-time inventory
tracking, payment processing, and invoicing.
Additionally, the database will play a crucial role in maintaining accurate stock
levels, preventing overselling, and facilitating secure transactions through various
payment gateways. Each order detail will be captured comprehensively, including the
necessary customer and payment information, along with applicable discounts.
2
CC5051NI Databases
1.1.2 Objectives
iii. To record and manage order details, including purchased products, quantities,
unit prices, and total order amounts.
iv. To manage vendor records for suppliers of electronic gadgets and associate
each product with a specific vendor.
vi. To integrate with various payment gateways to ensure secure and seamless
transactions for each order.
3
CC5051NI Databases
Gadget Emporium, an online electronics store, provides customers with a wide variety of
electronic devices and accessories. The platform offers a smooth experience for both
individual consumers and businesses, facilitating the purchase of electronic gadgets with
ease. The business focuses on precise product management, ensuring accurate details
such as product names, descriptions, categories, prices, and real-time stock levels.
Customers, categorized as Regular, Staff, or VIP, enjoy varying discount rates on
purchases, enhancing the appeal of the platform. The order processing system allows
customers to browse, select, and purchase multiple electronic gadgets online, with each
order systematically recorded, including product details, quantities, unit prices, and total
order amounts. Vendor management is a key aspect, maintaining records of vendors
associated with each product. Real-time inventory management prevents overselling and
ensures product availability. The integrated payment processing system offers secure
transactions through multiple gateways, including cash on delivery, credit/debit cards, or
e-wallets. Upon order confirmation, the system generates an invoice detailing the order,
customer information, and applicable discounts.
4
CC5051NI Databases
• Processing Orders: Customers have the flexibility to browse and buy one or more
electronic gadgets online. The system records detailed information for each order,
including the purchased products, quantities, unit prices, and the total order amount.
Orders may consist of multiple products, and a single product type might be part of
various orders placed by different customers.
5
CC5051NI Databases
• Generating Invoices: Upon customer order confirmation and checkout, the system
automatically generates invoices containing comprehensive details of the order,
customer information, and payment specifics, including applicable discounts.
6
CC5051NI Databases
1.4 Assumptions
• All customers must be categorized into one of the defined categories (Regular, Staff,
VIP).
• Each product is associated with a single vendor, and each vendor can supply many
products.
• Real-time product availability tracking implies a dynamic inventory that is updated with
each transaction.
• The system supports various payment gateways, providing flexibility for customers to
choose their preferred payment method.
• Each order requires a single payment option, ensuring clarity in the payment process
for each transaction.
7
CC5051NI Databases
1.5.1 Customer
8
CC5051NI Databases
1.5.2 Vendor
9
CC5051NI Databases
1.5.3 Orders
Order_ID NUMBER (5) PRIMARY KEY, This field records the unique ID
UNIQUE
assigned to each orders.
Order_Quantity NUMBER (5) NOT NULL This field records the amount of
products in the order.
Unit_Price NUMBER (11) NOT NULL This field records the unit price of
each product.
Total_Amount NUMBER (11) NOT NULL This field records the total amount
before discount.
Discount_Amount NUMBER (10) NOT NULL This field records the amount of
discount given to the order.
Final_Amount NUMBER (11) NOT NULL This field records the final amount
after discount.
Order_Date DATE NOT NULL This field records the
Ordered date of each order.
Customer_ID NUMBER (5) FOREIGN KEY This field records the unique ID of
customer which has given the order.
Payment_ID VARCHAR2 FOREIGN KEY This field records the unique ID of
(10)
each payment.
10
CC5051NI Databases
1.5.4 Product
11
CC5051NI Databases
2. Initial ERD
An entity is defined as an actual object or element existing in the tangible world, such as
a customer, car, or pen. These entities are stored within the database and need to be
discernible, ensuring they can be readily identified within a group (Point, 2023).
Entities Attributes
12
CC5051NI Databases
The initial ERD shows the relationship between the customer, order, product, and vendor
tables. The customer table contains information about the customer's name, address,
phone number, and email. The order table contains information about the order's date,
total amount, and payment information. The product table contains information about the
product's name, description, and price. The vendor table contains information about the
vendor's name, address, phone number, and email. The customer table and order table
has one to many relationship while order being optional as each customer can have
multiple orders and each order has one customer but customer can or cannot have order.
The order table and product table has many to many relationship as multiple order can
have multiple products and vice versa. The product table and vendor table have one to
13
CC5051NI Databases
many relationship as each vendor can sell multiple order and each product has one
vendor.
14
CC5051NI Databases
3. Normalization
In Unnormalized Form, the data in database are nor normalized which means they have
data redundancies, inconsistencies, repeating columns and all types of anamolies.
Process
15
CC5051NI Databases
Description
16
CC5051NI Databases
The concept of the first normal form (1NF) establishes foundational principles for
organizing relational databases and specifically applies to individual tables within the
database system. In first normal form, the repeating group or columns are eliminated by
creating different table for it.
• Identify each table with a unique column or a combination of columns known as the
primary key.
17
CC5051NI Databases
Process
Description
In the first normal form (1NF), repeating columns have been removed to ensure data
integrity. Since the Order table in UNF has repeating group i.e Product information, it is
ensured that Product table is defined as another table by having Order_ID as foreign key.
The "Order" table includes essential order details, while the "Product" table is related to
orders and focuses on product information. Each table has a primary key (Order_ID for
"Order" and Product_ID for "Product"), ensuring uniqueness and setting the foundation
for proper database organization.
18
CC5051NI Databases
The Second Normal Form eliminates the partial dependency on primary key, which
means the non-key attributes should be fully functional dependent on primary key and no
partial dependency should exist.
Process
19
CC5051NI Databases
So
Description
In achieving Second Normal Form (2NF), it is ensured that non-key attributes are fully
dependent on the primary key without any partial dependencies. In Product table all non-
key attributes were only dependent in Order_ID and existence of Product_ID causes
partial dependency in that table. So to remove the parital dependenct bridge table
Order_Product is created between the "Order" and "Product" tables. This bridge table
includes a composite primary key consisting of both the "Product_ID" and "Order_ID,"
ensuring a unique identifier for each combination. By doing so, it establishes a clear
relationship, avoiding partial dependencies and providing an organized structure where
non-key attributes in both the "Order" and "Product" tables are fully dependent on their
respective primary keys, leading to a 2NF-compliant database design.
20
CC5051NI Databases
The third normal form eliminates the transitive dependencies in the database which
means that no non-primary key attribute has transitively dependent relationships to
the primary key. If A -----> B and B -----> C that means C is transitively dependent on
A, so that transitive dependency is eliminated by making different table for it in 3NF
which helps to improve data consistency and redundancy and to remove all kinds of
anamolies.
Process
21
CC5051NI Databases
So
22
CC5051NI Databases
Description
In the transition to Third Normal Form (3NF), the primary objective is to eliminate transitive
dependencies, ensuring that non-primary key attributes do not have indirect relationships
with the primary key. This process involves recognizing instances where attributes like
Customer_Name, Customer_Address, Customer_PhoneNumber, and Customer_Email
were transitively dependent on Order_ID. To adjust this, a distinct "Customer" table was
established with Customer_ID as the primary key. Additionally, Payment_Option, found
to be transitively dependent on Order_ID, led to the creation of a separate "Payment"
table, with Payment_ID serving as the primary key. This restructuring enhances data
consistency, reduces redundancy, and ensures that each table aligns with the principles
of the Third Normal Form.
23
CC5051NI Databases
4. Final ERD
The final Entity Relationship Diagram represents the relationship diagram after the
normalization process.
24
CC5051NI Databases
• Orders: This entity serves as a repository for individual orders, covering crucial details
such as order quantity, unit price, discounts, final amounts, order dates, customer IDs,
and payment IDs.
• Products: Having comprehensive product information, this entity includes details like
product names, descriptions, categories, prices, final amounts, and stock quantities.
• Customers: Profiling customers, this entity stores relevant information such as names,
addresses, phone numbers, emails, categories, and applicable discount rates.
• Payments: This entity records diverse payment methods, featuring unique IDs and
associated payment options.
• Vendors: Managing vendor information, this entity includes details such as vendor
IDs, names, contact information, and addresses.
25
CC5051NI Databases
• Orders and Products: The "Order Product" table illustrates that a single order can
involve multiple products, mapping Order IDs to corresponding Product IDs.
• Orders and Customers: Each order is linked to a specific customer, as denoted by the
foreign key "Customer ID" within the Order table.
• Products and Vendors: The association between products and vendors is established
through the foreign key "Vendor ID" within the Product table.
Furthermore, the ERD has undergone normalization to optimize data organization and
integrity. This process strategically eliminates redundancy and reduces inconsistencies,
ensuring that data is stored both efficiently and accurately. The inclusion of primary keys
(PKs) for each entity guarantees a unique identifier for records, facilitating precise data
retrieval and modification. Foreign keys (FKs) sustains connections between related
entities, enhancing consistency and avoiding errors across tables.
26
CC5051NI Databases
5. Implementation
Figure 3: Screenshot of creating user, granting connect and resource and connecting to the user.
In the first part of implementation, it is required to create a different user for our
assignment to ensure that there is not any other tables in the specific user. It is created
by using create user command. It is also required to grant connect and resource, which
allows users to login and connect to Oracle database and provides other resources and
privileges. And all database table and queries for our assignment are done and stored in
this user account only. At last we need to connect to that user by simply typing it with
username and password.
27
CC5051NI Databases
The Customer table was successully created with 7 different attributes with Customer_ID
as primary key and other attributes with Not Null constraints. The table is created with all
attributes having suitable data types like Number and Varchar2. The customer table was
firstly created because it didn’t have any respective foreign key. The Customer table
stores all the information of customer.
28
CC5051NI Databases
The customer table is described in above table in SQL plus to retrieve the full information
of a customer table including datatype, column name and to check If the attribute is null
or not. In our table all the values are not null and Customer_ID is automatically assigned
as not null because it is primary key.
29
CC5051NI Databases
The Vendor table was successully created with 5 different attributes with Vendor_ID as
primary key and other attributes with Not Null constraints. The table is created with all
attributes having suitable data types like Number and Varchar2. The Vendor table stores
all the information of Vendor.
30
CC5051NI Databases
The vendor table is described in above table in SQL plus to retrieve the full information of
a vendor table including datatype, column name and to check If the attribute is null or not.
In our table all the values are not null and Vendor_ID is automatically assigned as not null
because it is primary key.
31
CC5051NI Databases
The Payment table was successully created with 2 different attributes with Payment_ID
as primary key and Payment_Option as Not Null constraints. The table is created with all
attributes having suitable data types lVarchar2. The Payment table stores all the
information of Payment done by Customers.
32
CC5051NI Databases
The payment table is described in above table in SQL plus to retrieve the full information
of a payment table including datatype, column name and to check If the attribute is null
or not. In our table all the values are not null and Payment_ID is automatically assigned
as not null because it is primary key.
33
CC5051NI Databases
The Product table was successully created with 7 different attributes with Product_ID as
primary key, Vendor_ID as foreign key and all other attributes as NOT NULL constraint.
Also the Product_Price attributes has Check constraint of greater than 0 because the
product price of the specific product cannot be less than 1 or 0. The table is created with
all attributes having suitable data types like Varchar2 and Number. The Product table
stores all the information of Products that are available in Gadget Emporium.
34
CC5051NI Databases
The product table is described in above table in SQL plus to retrieve the full information
of a product table including datatype, column name and to check If the attribute is null or
not. In our table all the values are not null excluding Vendor_ID (foreign key) and
Product_ID is automatically assigned as not null because it is primary key.
35
CC5051NI Databases
The Orders table was successully created with 9 different attributes with Order_ID as
primary key, Customer_ID and Payment_ID as foreign key and all other attributes as NOT
NULL constraint. Also the Order_Quantity, Unit_Price, Total_Amount and Final_Amount
attributes has Check constraint of greater than 0 because the values in those attributes
cannot be less than 1 or 0. The table is created with all attributes having suitable data
types like Varchar2, Number and Date. The Orders table stores all the information of
Orders that are ordered by the customers.
36
CC5051NI Databases
The orders table is described in above table in SQL plus to retrieve the full information of
a orders table including datatype, column name and to check If the attribute is null or not.
In our table all the values are not null excluding Customer_ID and Payment_ID (foreign
key) and Order_ID is automatically assigned as not null because it is primary key.
37
CC5051NI Databases
The Order_Product table was successully created with only 2 different attributes with
Order_ID and Product_ID as both Primary Key and Foreign Key. Actually, in this table
primary key is created by combination of both Order_ID and Product_ID which is known
as composite key. As Order_Product table is derived as Bridge table, it stores the
information of Product_ID of Order.
38
CC5051NI Databases
The Order_Product table is described in above table in SQL plus to retrieve the full
information of a table including datatype, column name and to check If the attribute is null
or not and both of the attributes are both primary key and foreign key as it is bridge table.
So, they are assigned as not null automatically. Both attributes have data type of Number.
39
CC5051NI Databases
All the relevant customer data are inserted in Customer table on the basis of their data
type. Insert all command is used to insert multiple values in same query. Also Select *
From Dual command is used to provide consistent way to structure INSERT ALL
command.
40
CC5051NI Databases
Figure 17: Screenshot of displaying all data of Customer table using SELECT * command.
All the values that were inserted in Customer table is displayed using Select * command.
This command displays all the values of attributes that are selected using select
command. So, all the information of customer are displayed here.
41
CC5051NI Databases
All the relevant vendor details are inserted in Vendor table on the basis of their data type.
Insert all command is used to insert multiple values in same query. Also Select * From
Dual command is used to provide consistent way to structure INSERT ALL command.
42
CC5051NI Databases
Figure 19: Screenshot of displaying all data of Vendor table using SELECT * command.
All the values that were inserted in Vendor table is displayed using Select * command.
This command displays all the values of attributes that are selected using select
command. So, all the information of vendor are displayed here.
43
CC5051NI Databases
All the relevant payment details are inserted in Payment table on the basis of their data
type. Insert all command is used to insert multiple values in same query. Also Select *
From Dual command is used to provide consistent way to structure INSERT ALL
command.
44
CC5051NI Databases
Figure 21: Screenshot of displaying all data of Payment table with SELECT * command.
All the values that were inserted in Payment table is displayed using Select * command.
This command displays all the values of attributes that are selected using select
command. So, all the information of payment are displayed here.
45
CC5051NI Databases
All the relevant product details are inserted in Product table on the basis of their data
type. Insert all command is used to insert multiple values in same query. Also Select *
From Dual command is used to provide consistent way to structure INSERT ALL
command.
46
CC5051NI Databases
Figure 23: Screenshot of displaying all data of Product table with SELECT * command.
All the values that were inserted in Product table is displayed using Select * command.
This command displays all the values of attributes that are selected using select
command. So, all the information of product are displayed here.
47
CC5051NI Databases
All the relevant order details are inserted in Orders table on the basis of their data type.
Insert all command is used to insert multiple values in same query. Also Select * From
Dual command is used to provide consistent way to structure INSERT ALL command.
48
CC5051NI Databases
Figure 25: Screenshot of displaying all data of Orders table with SELECT * command.
All the values that were inserted in Orders table is displayed using Select * command.
This command displays all the values of attributes that are selected using select
command. So, all the information of orders are displayed here.
49
CC5051NI Databases
All the relevant order details are inserted in Order_Product table on the basis of their data
type. Insert all command is used to insert multiple values in same query. Also Select *
From Dual command is used to provide consistent way to structure INSERT ALL
command.
50
CC5051NI Databases
All the values that were inserted in Order_Product table is displayed using Select *
command. This command displays all the values of attributes that are selected using
select command. So, all the information of Order_Product are displayed here.
51
CC5051NI Databases
6. Database Querying
a) List all the customers that are also staff of the company.
Figure 28: Query to list all customers that are staff of the company.
The query retrieves and displays customers who hold the designation of "Staff" within the
company. It provides a detailed list of these staff customers, including their ID, name,
address, phone number, email, customer category, and associated discount rates. This
information aids in identifying and managing staff members among the customer base.
52
CC5051NI Databases
b) List all the orders made for any particular product between the dates 01-05-
2023 till 28- 05-2023.
Figure 29: Query to list all the orders between the mentioned date.
The query retrieves and displays orders placed for any specific product within the
specified date range of May 1, 2023, to May 28, 2023. It provides details such as order
ID, order quantity, unit price, total amount, discount amount, final amount, order date,
customer ID, and payment ID. This information is useful for tracking and analyzing orders
for a particular product during the specified period, aiding in inventory management and
sales analysis.
53
CC5051NI Databases
c) List all the customers with their order details and also the customers who have
not ordered any products yet.
Figure 30: Query to list all customers with order details and also the customers who have not ordered yet.
This query combines customer details with order information, listing customers who have
placed orders along with their respective order details. It utilizes a LEFT JOIN between
the “CUSTOMER” and “ORDERS” tables, allowing the inclusion of customers who have
not placed any orders, with their details presented and order-related columns with blank
output. For instance, customers like Rijan Paudel, Jenish Katuwal, Chris Evans, and Miraj
Bhandari have not made any orders, so their order details is blank. The result provides a
comprehensive overview of all customers and their order history, including those without
any recorded orders.
54
CC5051NI Databases
d) List all product details that have the second letter ‘a’ in their product name and
have a stock quantity more than 50.
Figure 31: Query to list all the products with second letter 'a' in product name and have stock quantity more than 50.
The query retrieves product details for items with the second letter “a” in their names and
a stock quantity exceeding 50. The results include products such as the Samsung S23
Ultra, Galaxy Electric Toothpaste, Galaxy Smart Watch, Laxmi Joystick, Samsung PS4,
and Macbook Air M1. These products, identified by their names and stock quantities,
meet the specified criteria, providing a brief overview of relevant items in the inventory.
55
CC5051NI Databases
Figure 32: Query to list the customer who has ordered recently.
This query retrieves the customer who has made the most recent order, displaying
essential details such as customer ID, name, order ID, quantity, final amount, and order
date. It achieves this by joining the `Customer` and `Orders` tables based on the customer
ID, then filtering for the order with the latest order date using a subquery with “MAX
(Order_Date)”. The result provides concise information about the most recent customer
order.
56
CC5051NI Databases
Figure 33: Query to show total revenue of company for each month.
The query calculates the total revenue of the company for each month by extracting the
month and year from the “Order_Date” column and grouping the results accordingly. It
uses the “TO_CHAR” function to format the date as “MM-YYYY”. The total revenue for
each month is obtained by summing the “Final_Amount” column. The results are then
ordered chronologically. For example, in January 2023, the total revenue is 97,200, and
the pattern continues for subsequent months. This query provides a clear overview of
the company's monthly revenue trends.
57
CC5051NI Databases
b) Find those orders that are equal or higher than the average order total value.
Figure 34: Query to find those orders that are equal or higher than average order total value.
The query retrieves orders with a final amount equal to or higher than the average order
total value. It achieves this by comparing the 'Final_Amount' of each order with the
subquery that calculates the average final amount using the “AVG” function. The result
includes orders with Order ID 353, 357, 359, 362, and 363, which meet the criteria of
being equal to or exceeding the average order total value. This query is useful for
identifying orders with above average financial significance.
58
CC5051NI Databases
c) List the details of vendors who have supplied more than 3 products to the
company.
Figure 35: Query to list details of vendors who have supplied more than 3 products.
The query retrieves details of vendors who have supplied more than 3 products to the
company. It accomplishes this by joining the 'Vendor' and 'Product' tables based on the
common “Vendor_ID” and then using the “COUNT” function to calculate the number of
products supplied by each vendor. The “HAVING” clause filters the results to include only
those vendors with a product count greater than 3. The output includes information such
as Vendor ID, Vendor Name, Vendor Phone Number, Vendor Email, Vendor Address,
and the count of products supplied. In the provided results, vendors like Evo Store and
Gautam Electronics meet the criteria by supplying 5 and 4 products, respectively.
59
CC5051NI Databases
d) Show the top 3 product details that have been ordered the most.
Figure 36: Query to show top 3 product details that were ordered the most.
The query retrieves the top 3 products with the highest order count. It calculates the total
number of orders for each product by joining the "Product" and "Order_Product" tables,
grouping the results by various product attributes, and sorting them in descending order
based on the order count. The final output includes details such as product ID, name,
description, category, price, stock quantity, vendor ID, and the calculated total order
count. This query is valuable for identifying the most popular products in terms of order
frequency.
60
CC5051NI Databases
e) Find out the customer who has ordered the most in August with his/her total
spending on that month.
Figure 37: Query to find customer who has most ordered the most in August with his/her total spending of that month.
The query retrieves the customer who has made the most orders in August along with
their total spending for that month. It achieves this by joining the "Customer" and "Orders"
tables, filtering the results for orders placed in August 2023, grouping them by customer
ID and name, calculating the sum of the final amounts for each customer, and ordering
the results in descending order based on total spending. The outer query then selects the
top row using the ROWNUM constraint, limiting the output to the customer with the
highest spending in August. In this specific example, the result shows that customer with
ID 111, named Sher Deuba, has the highest total spending of 270,900 in August 2023.
61
CC5051NI Databases
7. Critical Evaluation
7.1 Critical Evaluation of module, its usage and relation with other subject
Database is one of the most important and helpful subject or technical knowledge that
one can gain for being top in IT and other business related careers. It helps to choose
very diverse career options in IT and other career. And having very good foundational
base is very important in database. Our module tutors have played very significant role
for developing these foundational base of database by providing practical knowledge of
database management and SQL. While the module has been instrumental in building a
solid foundation in database management and SQL, there's room for improvement. The
practical aspect of working with databases is a key component in real-world scenarios.
Therefore, incorporating hands-on experience with database workbenches, rather than
just command-line operations, could enhance the learning experience. This practical
approach aligns more closely with industry practices, preparing effective transitions into
professional roles where databases are managed through dedicated workbenches.
The knowledge gained in the database module is closely interlinked with other
subjects, forming a integrated understanding of IT systems. For instance, databases play
a crucial role in the development and functionality of software applications, making the
knowledge gained in this module applicable to software engineering and development
subjects. Additionally, the management and utilization of data are integral to broader
subjects like data science and analytics, where database skills become highly relevant.
62
CC5051NI Databases
The coursework structure effectively guides us through the details of database design
and implementation. The introduction of a detailed case study for "Gadget Emporium"
provides a realistic context, shaping the database design with clear business rules. The
breakdown of tasks, from the initial ERD to normalization. However, there is an
opportunity to increase practical involvement, especially during the implementation
phase. This would improve the application of theoretical concepts and provide a more
hands-on learning experience.
The case study is robust, offering a subtle understanding of business requirements. The
SQL queries align smoothly with the specified business rules, providing both information
and transactional queries. Exploring deeper into challenges encountered during the
design and implementation phases would enhance the evaluation section, providing
valuable insights into decision-making processes.
63
CC5051NI Databases
Creating a dump file of your database in SQL Plus is essential for coursework
submissions. These files serve as backups, providing a snapshot of your database for
potential restoration. In the context of coursework, dump files simplify data sharing with
tutors, ensuring they can easily assess your work while maintaining data accuracy and
consistency. Tutors can use these files to review your database at a specific point in time,
enhancing the overall integrity of your coursework submissions.
64
CC5051NI Databases
Creating a spool file in SQL Plus is vital for coursework submissions and general
database situations. In coursework, it is crucial as the spool file captures SQL Plus output,
documenting queries and results, providing a detailed record for assessment and
potential troubleshooting. In general situations, spool files serve as essential logs,
tracking commands, errors, and results in SQL Plus sessions. They offer valuable
references for analysis, debugging, and auditing, contributing to effective database
management practices.
65
CC5051NI Databases
66
CC5051NI Databases
67
CC5051NI Databases
68
CC5051NI Databases
69
CC5051NI Databases
70
CC5051NI Databases
71
CC5051NI Databases
72
CC5051NI Databases
73
CC5051NI Databases
74
CC5051NI Databases
75
CC5051NI Databases
76
CC5051NI Databases
Figure 55: Screenshot of showing that all tables have been dropped successfully.
77
CC5051NI Databases
11. Conclusion
In conclusion, the coursework effectively guided the exploration of database design and
implementation, terminating in a robust database system for "Gadget Emporium." The
initial ERD served as the foundation for the subsequent normalization process, which
ensured data integrity and adherence to database principles. The implementation phase
brought the conceptual design to life, creating tables, inserting relevant data, and
establishing relationships among entities.
Despite the strengths of the coursework, there remains room for improvement.
Enhancing the practical component by incorporating hands-on exercises with database
workbenches would align the learning experience more closely with industry practices.
Additionally, delving into the challenges faced during the design and implementation
phases would enrich the evaluation section, showcasing the decision-making process
and providing valuable lessons for future database activities.
78
CC5051NI Databases
12. References
79