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

Final Project Database

The document describes a database system for a showroom management project. It includes tables for employees, addresses, salaries, products, suppliers, customers and orders. It also includes sample data and SQL code to implement the database system.

Uploaded by

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

Final Project Database

The document describes a database system for a showroom management project. It includes tables for employees, addresses, salaries, products, suppliers, customers and orders. It also includes sample data and SQL code to implement the database system.

Uploaded by

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

VIETNAM NATIONAL UNIVERSITY, HANOI

INTERNATIONAL SCHOOL
----------------------

Final Project
DATABASE SYSTEMS
Lecturer’s name: Truong Cong Doan

Group 9’s members:


● Nguyen Bich Diep_21070891
● Truong Gia Huy_21070439
● Hoang Thi Phuong Thao_21070818
● Do Dinh Khai_21070128

Project’s name: Showroom management

Class: INS208002

January, 2023
INS208002

Table of Contents

CHAPTER I: INTRODUCTION ............................................................................... 2

CHAPTER II: DATABASE SYSTEM IMPLEMENTATION ................................. 8

I) Analyze queries from the database system......................................................... 8

II) High level Database model ............................................................................... 9

III) Normal Forms of Database system ................................................................ 10

IV) Code SQL ...................................................................................................... 10

V) Member’s Works............................................................................................. 19

CHAPTER III: CONCLUSION ............................................................................... 20

1|Page
INS208002

CHAPTER I: INTRODUCTION
The Showroom Management System will help the business in tracking the inventory
movements in the warehouse by item, serial number. A Showroom Management
Solution is extremely critical to ensure smooth running of your retail business. A
Showroom Management Solution should be adaptable and secure to convey the right
client service. These systems must be driven by access to real-time client data. At
exactly that point can retailers convey customized offers and services that are up to
the moment and targeted to each individual. The effectiveness of database
administration to manage data has been recognized by organizations. Data
management is often critical to management decisions, and the success of
management decisions is critical to strengthening business organizations.

A Showroom Management System software is extremely critical to ensure smooth


running of your retail business. Store management systems should be adaptable and
secure to convey the right client service.

For your convenience, we have created a Showroom Management System on


Database Design that has been written exclusively.

Key Results of Showroom Management System.

Easy Identification of all material stored.

● Receipt of incoming goods.


● Inspection of all receipts.
● Storage and preservation.
● Stores accounting.
● Controlled Inventory.
● Easy for Stock-taking.

2|Page
INS208002
This database system includes seven relations.

The Employee relation gives the FirstName, LastName, ID, Date of birth and
Gender various Employees. For convenience, we assume that Employee IDs are
unique to all Employees.
The Address relation gives essential information about the Employee,
including their ID, Address, Hometown, City, Nationality, Email, and Phone
Number.
The Salary relation provides the salary Employees will be gotten, including
ID, Attendance, Position, Basic Salary.
The Product table, which displays information about the Product ID, Product
Name, Quantity, Cost, Origin. We also assume Product ID is unique to easily
supervise.
The Supplier relation tells about Product ID, Supplier Name, Supplier ID,
Number product supplied.
The Customer table gives essential information about the Customers of
Showroom including Customer ID, Customer Name, Customer Address and their
Phone Number. It can convey customized offers and services that are up to the
moment and targeted to each individual.
The Order relation displays Order ID, Customer ID, Product ID, Number
product.

3|Page
INS208002

Sample data for relation Employee.

Sample data for relation Address

4|Page
INS208002

Sample data for relation Salary

Sample data for relation Product

5|Page
INS208002

Sample data for relation Supplier

Sample data for relation Customer

6|Page
INS208002

Sample data for relation Order

7|Page
INS208002

CHAPTER II: DATABASE SYSTEM IMPLEMENTATION


I) Analyze queries from the database system
There are twenty queries about the requirements in practice for this database. The
SQL codes answering these queries are located in section 4: Code SQL

1. View employee information, employee's address


2. Calculate avg, max, min, sum of employee's basic salary
3. Add new employee information
4. Find products under 5 million VND
5. Add new product
6. Delete 1 product when out of stock
7. Find the supply chain in order from most to least
8. Find Customer IDs to buy tiles 80x80
9. Find customer information by order ID
10.Find the name of the employee who is not on leave
11.Count the number of male and female employees in the company
12.Count the number of employees in the company
13.Find supplier information by product
14.Delete products originating from Japan
15.List all products originating from China

8|Page
INS208002

II) High level Database model

9|Page
INS208002
III) Normal Forms of Database system
- Employee (FirstName, LastName, ID, Dob, Gender)
- Address (ID, Address, Hometown, City, Email,Phone)
- Salary (ID, Attendance, Position, Basic_Salary)
- Product (Prod_ID, Prod_Name, Quantity, Cost, Origin)
- Supplier (Prod_ID, Sup_Name, Sup_ID, Number_prod_supplied)
- Customer (Cus_ID, Cus_Name, Cus_Address, Cus_phone)
- Order (Order_ID, Cus_ID, Prod_ID, Number_prod)
IV) Code SQL
CREATE DATABASE FINAL
USE FINAL
GO

CREATE TABLE Employee


(
FirstName CHAR(30),
LastName CHAR(30),
ID VARCHAR(30) NOT NULL PRIMARY KEY,
Dob SmallDateTime,
Gender CHAR(10),
)

CREATE TABLE Address


(
ID VARCHAR(30) NOT NULL PRIMARY KEY,
Address VARCHAR(50),
Hometown CHAR(30),
City CHAR(30),
Email VARCHAR(30),
Phone text,
constraint fk_Address_Employee FOREIGN KEY(ID) REFERENCES
Employee(ID)
);

10 | P a g e
INS208002

CREATE TABLE Salary


(
ID VARCHAR(30) NOT NULL PRIMARY KEY,
Attendance VARCHAR(20),
Position CHAR(30),
Basic_Salary INT,
constraint fk_Salary_Employee FOREIGN KEY(ID) REFERENCES
Employee(ID) ON DELETE CASCADE
);

CREATE TABLE Product


(
Prod_ID VARCHAR(30) NOT NULL PRIMARY KEY,
Prod_Name VARCHAR(30),
Quantity INT,
Cost VARCHAR(30),
Origin VARCHAR(30)
)

CREATE TABLE Supplier


(
Prod_ID VARCHAR(30) NOT NULL PRIMARY KEY,
Sup_Name VARCHAR(30),
Number_prod_supplied INT,
constraint fk_Supplier_Product FOREIGN KEY(Prod_ID) REFERENCES
Product(Prod_ID) ON DELETE CASCADE
);

CREATE TABLE Orders


(
Order_ID VARCHAR(10) NOT NULL PRIMARY KEY,
Cus_ID VARCHAR(30),
Prod_ID VARCHAR(30),
Number_prod VARCHAR(30),
constraint fk_Order_Product FOREIGN KEY(Prod_ID) REFERENCES
Product(Prod_ID) ON DELETE CASCADE

11 | P a g e
INS208002
);

CREATE TABLE Customer


(
Cus_ID VARCHAR (30) NOT NULL PRIMARY KEY,
Cus_Name VARCHAR (50),
Cus_Address VARCHAR (100),
Cus_phone TEXT,
constraint fk_Customer_Order FOREIGN KEY(Cus_ID) REFERENCES
Customer(Cus_ID)
);

---Insert Data into tables


INSERT INTO Employee
VALUES
('Tran','Trung Ha',1,'1975-04-23','Male'),
('Truong','Thi Hoa',2,'1990-03-28','Female'),
('Nguyen','Van Hung',3,'1985-05-30','Male'),
('Nguyen','Thi Hoa',4,'1992-04-04','Female'),
('Nguyen','Huy Hoang',5,'1994-09-23','Male'),
('Vu','Van Dung',6,'1989-01-14','Male'),
('Nguyen','Thu Trang',7,'1991-05-01','Female'),
('Tran','Van Nam',8,'1990-07-05','Male'),
('Do','Hoang Hiep',9,'1995-09-04','Male'),
('Nguyen','Thu Thao',10,'1990-05-12','Female');

INSERT INTO Address


VALUES
(1,'48 Vo Chi Cong, Ngu Hanh Son District','Da Nang','Da
Nang','[email protected]','093 1234 042'),
(2,'52 Dai An 5, Ngu Hanh Son District','Da Nang','Da Nang','[email protected]','034
9520 492'),
(3,'64 Nam Son 1, Hai Chau District','Hue','Da Nang','[email protected]','072
8330 203'),
(4,'63 Le Thanh Ton, Hai Chau District','Nghe An','Da
Nang','[email protected]','034 9342 400'),

12 | P a g e
INS208002
(5,'29 Chinh Huu, Son Tra District','Quang Nam','Da
Nang','[email protected]','098 0931 413'),
(6,'95 Doi Can, Cam Le District','Quang Nam','Da
Nang','[email protected]','098 2732 494'),
(7,'20 Cao Ba Dat, Hoa Vang District','Hue','Da
Nang','[email protected]','093 3492 403'),
(8,'19 Pham Tu, Son Tra District','Ha Tinh','Da Nang','[email protected]','072 4283
050'),
(9,'50 Pham Cu Luong, Son Tra District','Da Nang','Da
Nang','[email protected]','072 0842 421'),
(10,'255 My Khe 2, Son Tra District','Quang Ngai','Da
Nang','[email protected]','093 5825 588');

INSERT INTO Salary


VALUES
(1,'Full_time','Manager','30000000'),
(2,'Full_time','Secretary','15000000'),
(3,'Full_time','Carrier','7000000'),
(4,'Full_time','Carrier','7000000'),
(5,'Absent_2_day','Carrier','6700000'),
(6,'Absent_1_day','Carrier','6900000'),
(7,'Absent_1_day','Sales agent','6900000'),
(8,'Full_time','Sales agent','10000000'),
(9,'Full_time','Sales agent','10000000'),
(10,'Absent_1_day','Sales agent','9800000');

INSERT INTO Product


VALUES
('T192','Tiles 80x80 (m2)', 902, 1280000,'China'),
('T193','Tiles 60x60 (m2)', 49, 800000,'China'),
('T191','Tiles 30x60 (m2)', 41, 900000,'Japan'),
('T190','Tiles 30x30 (m2)', 95, 990000,'S.Korea'),
('A186','Alkaline primer AL01', 502, 1200000,'Germany'),
('E173','Exterior paint AP03', 593, 3000000,'Germany'),
('I170','Interior paint AP04', 292, 4000000,'Japan'),
('W043','Waterproof paint K23', 405, 1000000,'Japan'),

13 | P a g e
INS208002
('TL73','Toilet table AC900VRN', 23, 5500000,'Thailand'),
('TL75','Toilet table AC504VAN', 0, 5000000,'Malaysia');

INSERT INTO Supplier


VALUES
('T192','Taicera',400),
('T193','Taicera',30),
('T191','Taicera',50),
('T190','Big House',25),
('W043','Taicera',30),
('TL73','Viglacera',23),
('TL75','Viglacera',21),
('A186','Nippon Paint',291),
('I170','Nippon Paint',123),
('E173','Nippon Paint',466);

INSERT INTO Orders


VALUES
(100,'B100','T190',80),
(101,'B101','TL75',3),
(102,'C102','T191',30),
(103,'H103','T190',70),
(104,'DN104','T192',1000),
(105,'L105','E173',6),
(106,'DN106','W043',205),
(107,'T107','TL73',3),
(108,'N108','E173',5),
(109,'H109','TL73',2);

INSERT INTO Customer


VALUES
('B100','Nguyen Anh Binh','902 Duy Tan, Hai Chau District','096 8888 888'),
('B101','Nguyen Anh Tuan','903 Duy Tan, Hai Chau District','096 8888 999'),
('C102','Tran Van Cuong','41 Pham Xuan An, Cam Le District','032 5611 622'),

14 | P a g e
INS208002
('H103','Vu Minh Huy','95 Vo Chi Cong, Cam Le District','034 7117 672'),
('DN104','Dien Nam Dien Ngoc Industrial Zone','W7P4+CQG, ĐT607, Dien Nam Trung,
Hoi An City, Quang Nam','098 8338 292'),
('L105','Le Van Lam','593 Le Van Hien, Ngu Hanh Son District','072 4953 049'),
('DN106','Dien Nam Dien Ngoc Industrial Zone','W7P5+CQG, ĐT608, Dien Nam Trung,
Hoi An City, Quang Nam','098 8338 292'),
('T107','Nguyen Van Thanh','405 Ho Xuan Huong, Ngu Hanh Son District','016 9292
929'),
('N108','Nguyen Nhat Nam','23 Me Thu, Cam Le District','093 1220 201'),
('H109','Ha Thi Hong','21 Con Dau, Cam Le District','048 8393 312');

--1
--View employee information, employee's address--
SELECT Employee.ID, Employee.FirstName,
Employee.LastName,Address.Email,Address.Phone,Address.Address,Address.City
FROM Employee, Address
WHERE Employee.ID=Address.ID

--2
--Calculate avg, max, min, sum of employee's basic salary--
SELECT AVG(Basic_Salary) AS Average_of_Salary, MAX(Basic_Salary) AS
Max_of_Salary, MIN(Basic_Salary) AS Min_of_Salary, SUM(Basic_Salary) AS
Total_Salary
FROM Salary

--3
--Add new employee information--
CREATE TRIGGER Insert_new_employee
on Employee
FOR INSERT
AS
BEGIN
DECLARE @insertedrow INT
SELECT @insertedrow=count(*)
FROM inserted
PRINT CAST(@insertedrow AS VARCHAR(30))+ 'Row are inserted'
END

15 | P a g e
INS208002
INSERT INTO Employee(FirstName,LastName,ID,Dob,Gender)
VALUES('Nguyen Quang','Tuan Anh','11','1992-08-10','Male')
SELECT * FROM Employee

--4
--Find products under 5 million VND--

SELECT Prod_ID, Prod_Name, MIN(Cost) AS "Cheap_product"


FROM Product
WHERE Cost < 5000000
GROUP BY Prod_ID, Prod_Name

--5
--Add new product--
CREATE TRIGGER Insert_new_product
on Product
FOR INSERT
AS
BEGIN
DECLARE @insertedrow INT
SELECT @insertedrow=count(*)
FROM inserted
PRINT CAST(@insertedrow AS VARCHAR(30))+ 'Row are inserted'
END
INSERT INTO Product(Prod_ID,Prod_Name,Quantity,Cost,Origin )
VALUES('WS16','Wash_stand','11','1500000','Japan')
SELECT * FROM Product

--6
--Delete 1 product when out of stock--
CREATE TRIGGER Out_of_product
ON Product
FOR DELETE
AS
BEGIN
DECLARE @deletedrow int
SELECT @deletedrow =count(*)

16 | P a g e
INS208002
FROM deleted
PRINT CAST(@deletedrow as nvarchar(10))+ 'Out of product'
END
DELETE FROM Product WHERE Quantity= '0';
SELECT * FROM Product

--7
--Find the supply chain in order from most to least--
SELECT * FROM Supplier
ORDER BY Number_prod_supplied DESC

--8
--Find Customer IDs to buy tiles 80x80--
SELECT Cus_ID,Prod_ID,Order_ID,Number_prod
FROM Orders
GROUP BY Cus_ID,Prod_ID,Order_ID,Number_prod
HAVING Prod_ID ='TL73'
SELECT * FROM Orders

--9
--Find customer information by order ID--
SELECT Customer.Cus_ID,
Customer.Cus_Name,Customer.Cus_phone,Customer.Cus_Address
FROM Customer
JOIN Orders ON Orders.Cus_ID = Customer.Cus_ID
WHERE Order_ID = '100'
ORDER BY Customer.Cus_Name

--10
--Find the name of the employee who is not on leave--
SELECT Employee.LastName, Employee.ID
FROM Employee
JOIN Salary ON Employee.ID = Salary.ID
WHERE Attendance = 'Full_time'
ORDER BY Salary.Attendance;

17 | P a g e
INS208002
--11
--Count the number of male and female employees in the company--
SELECT Gender, count(*) AS Total from Employee
GROUP BY Gender;

--12
--Count the number of employees in the company--
SELECT count(ID) as NumberOfEmps
FROM Employee;

--13
--Find supplier information by product--
SELECT Supplier.Sup_Name, Supplier.Prod_ID
FROM Supplier
JOIN Product ON Supplier.Prod_ID = Product.Prod_ID
WHERE Product.Prod_ID = 'E173'
ORDER BY Supplier.Sup_Name

--14
--Delete products originating from Japan--
DELETE
FROM Product
WHERE Origin='Japan'
SELECT * FROM Product

--15
--List all products originating from China--
SELECT Prod_Name, Prod_ID, Origin
FROM Product
WHERE Origin='China';

18 | P a g e
INS208002
V) Member’s Works
Member Work

+ Convert the Database model into Normal forms

+ Insert the data into the database

Nguyen Bich Diep + Code for queries

+ Write the report

+ Support

+ Draw High-level database model

+ Prepare the sample data for Introduction


Truong Gia Huy
+ Create tables

+ Code for queries

+ Code for queries


Hoang Thi Phuong Thao
+ Support

+ Write the script for Introduction

+ Create table

Do Dinh Khai + Code for queries

+ Present

+ Support

19 | P a g e
INS208002

CHAPTER III: CONCLUSION


Through the course, we self-assess what we have learned:

- Firstly, we understand the importance of applying technology to data analysis.

- Second, we learned how to apply SQL Server tools to enhance data presentation
and analysis performance.

- Next, we learned useful knowledge about:

+ Overview of databases, definitions of database structures

+ Learn and grasp about Relational Database Modeling

+ Understand The Database Language SQL

- Moreover, we learned how to work as a team, improve our thinking, and reflect
on database problems.

Therefore, we believe that they will help us in the future learning process.

20 | P a g e

You might also like