Beruflich Dokumente
Kultur Dokumente
First of all, a special and big thank you goes to my family for giving
encouragement, enthusiasm and invaluable assistant to me. Without all this, I might
not be able to complete this assignment properly.
iv
TABLE OF CONTENT
ACKNOWLEDGMENTS iv
TABLE OF CONTENT v
CHAPTER 1: INTRODUCTION................................................................................1
1.3.1. Advantages..................................................................................5
1.3.2. Disadvantages..............................................................................5
2.1. Normalization..................................................................................6
v
3.1.6. DETAIL table..............................................................................12
CONCLUSION......................................................................................................31
REFERENCES
vi
LIST OF TABLES & FIGURES
vii
Table 4.3: Query of recoding................................................................................30
viii
Design a relational database system for a uniform shop
CHAPTER 1: INTRODUCTION
Vi Vi Shop which is located on Tran Cao Van Street, Da Nang City, is a fashion
shop specializing in selling school uniforms at all grades. They plan to expand sales
online as well as open more branches, so they are looking to apply the current data
storage system with a relational database.
Customers can purchase any quantity of many items that Vi Vi Shop has in its
current catalog. The catalog includes boys' shirt and trousers, girls' shirt and
trousers, dress, and skirt. Each category has many sizes.
Vi Vi Shop would like to add all the customers’ information to the database so
that they can offer more services to their customer, for example, home delivery or
sending an e-mail with offers that are available. So at least one of these contact
method, customer’s address, phone number or email must be entered.
Because of the need to expand the business, sellers’ information also needs to
be stored. Sellers at Vi Vi Shop will be paid a monthly bonus which is determined by
the number of sales they have made for each month.
The shop currently stores data in two ways: paper books and an excel file.
When a customer buys products, a seller writes a receipt on a paper book and gives
it to the customer. A copy of the receipt is saved and based on that, the shop owner
would aggregate data and store it into the excel file at the end of the day. Below is a
retail receipt form.
All data is stored in an excel file. Excel sheets include Sell sheet, Stock sheet,
Skirt sheet, Dress sheet, etc. in which, Sell sheet stores sales data, Stock sheet
stores input data, the remaining sheets store details about categories. Here are
details of each sheet of the excel file.
Information stored in Sell sheet is daily sales information including date, item’s
name, quantity sold, total amount, total input value. The shop only stores items with
the common name of HS. Quantity sold is the total products sold by any item. Total
amount is the total turnover of the day. The shop uses the formula in Excel to
calculate the total turnover of all days with the aim of viewing the difference
between revenue and total value of input. The difference would be considered a
profit only when the shop has recovered its capital.
This sheet contains the shop’s input data. The information stored includes date
received goods, category, size, quantity received, unit price, total price, total value.
This sheet contains detailed information about boys ’shirt category. This
category has many sizes from small ones such as 9, 10, 11, 12, to bigger ones such
as S, M, 2XL, 3XL, etc. Each size has different stock price, sell price and profit.
1.3.1. Advantages
Storing data as above is quite simple. Information is clear, meeting the shop's
current needs and purposes.
1.3.2. Disadvantages
Archived information is general, not detailed. There are multiple duplicate data.
This storing method cannot meet new needs or business expansion because of some
disadvantages. For example, the shop can not manage inventory products, specific
sales information or sales on each type of category, each size, etc.
The above problems can be solved by building a relational database system for
the shop and dividing information that needs to be managed into accurate and clear
tables. The advantages of this database are:
All information can be stored easily and quickly. Then the system would have
enough information to cater to all the needs of the shop, such as checking inventory,
sales statistics by each category, each seller, etc.
2.1. Normalization
After analyzing the current way of storing data, the collected information, as
well as the shop's requirements with the database, information to be managed would
include: ReceiptID, Date, SellerID, SellerName, SellerBirthday, SellerAddress,
SellerPhone, SellerEmail, CustomerID, CustomerName, CustomerBirthday,
CustomerAddress, CustomerPhone, CustomerEmail, CategoryID, CategoryName,
ProductID, Size, StockPrice, SellPrice, QuantitySold, QuantityReceived.
StockPrice is the entry price of the product and SellPrice is the price of the sale.
QuantitySold is the quantity sold of the same product in a receipt, and
QuantityReceived is the total items of the same product entered in the warehouse.
ReceiptID is selected as the primary key for the non-normalized table. The
table needs to be flattened to make sure a table cell contains only one value and
specified the repeating attributes in the non-normalized table for the ReceiptID key
attribute. In a receipt, the attributes: CategoryID, CategoryName, ... repeat several
times so they need to be separated into a new table, DETAIL (ReceiptID,
CategoryID, CategoryName, ProductID, Size, StockPrice, SellPrice, QuantitySold,
QuantityReceived), in which, ReceiptID and ProductID combine to form the
primary key of this new table.
After normalization, the database will be organized into the following tables:
The following figure shows the ERD of the database after normalization.
In fact, a customer can buy many times and have many receipts. A seller can
sell many times and create many receipts as well. Therefore, the relationships
between Customer and Receipt, between Seller and Receipt are 1 - n.
A category includes many products which are different sizes of the category.
The relationship between Category and Product is also a 1 - n relationship. Each
product sold in each receipt is a value of Detail. A receipt can have many products,
so the relationship between Receipt and Detail is a 1 - n relationship.
The database includes separate tables for different objects that make data
management more efficient. Data is managed clearly, consistently. Redundancies can
be avoided while still ensuring data integrity.
and CustomerEmail, the other columns must not be empty. The value of the
CustomerBirthday column must be smaller than the data creation date. Details of the
CUSTOMER table are shown in the table below:
Allow
Column name Data Type Constraint
null
ProductID nvarchar(10) No PK
CategoryID nvarchar(10) No FK
Size nvarchar(5) No
StockPrice int No Check (StockPrice > 0)
SellPrice int No Check (SellPrice > 0)
Check (QuantityReceived >
QuantityReceived int No
0)
Information of the sellers is added to the SELLER table by executing the Insert
statement as follows:
The Update statement is used when needing to change data in the table. For
example, below is the query to update the phone number of the seller Nguyen Van
Lam with ID S003 into number 0944561362.
UPDATE SELLER
SET SellerPhone = '0944561362'
WHERE SellerID = 'S003'
The Delete statement is used to delete a row of a table. The example below is
the query to delete information of the seller with ID S003 from SELLER table.
After completing the data entry for the database, the tables containing data are
shown below.
Every week, the shop needs to check the remaining quantity of each product in
stock. The following view is used to show statistics of the total number of items sold
and the inventory of each product.
The shop wants to know sales and profits every day of the month. The
following view is used to calculate the total number of products sold, the total
revenue and total profit by day in July 2019.
At the end of the month, the shop sums up the sales of each seller and gives
bonus money. The following view is used to calculate the total number of products
each seller sold and the total revenue of each seller in July 2019. Results are sorted
in descending order by revenue.
The shop can review all information about a specific receipt. The following view
is used to review the information of a receipt which ReceiptID is R0002.
The shop is going to launch a promotion for loyal customers whose birthday is
in August. Loyal customers are defined as customers who have purchased products
twice or more. The following view lists customers who have purchased at least twice
and have birthday in August.
What is
Tes
being How Test data used Expected results
t
tested
Failure when inputting
Data of a new
Reverse the order data into RECEIPT
Order of receipt in
of data entry as table, an error
input RECEIPT table:
1 follows: message box appears
on data entry ‘R0010’, ‘2019-
1. Receipt table because there is no
screen 08-19’, ‘S004’,
2. Seller table Seller ‘S004' assigned
‘C0005’
in SELLER table
Failure when inputting
Data of a new
Reverse the order data into PRODUCT
Order of product in
of data entry as table, an error
input PRODUCT table:
2 follows: message box appears
on data entry ‘P020’, ‘BO’, ‘11’,
1. Product table because there is no
screen ‘70000’,
2. Category table Category ‘BO' assigned
‘100000’, ‘50’
in CATEGORY table
Data of a new
customer in Failure when inputting
Enter a value that
CUSTOMER data into CUSTOMER
has more than 10
table: table, an error
Validation of characters into
3 ‘C0000000009’ message box appears
input CustomerID
, ‘Nguyen Van A’, because the limit of
column of
‘1997-09-03’, ’50 CustomerID length is
CUSTOMER table
Le Do’, 10 characters
‘0977888999’
Data of a new Failure when inputting
Enter a real product in data into PRODUCT
Validation of number into PRODUCT table: table, an error
4
input StockPrice column ‘P020’, ‘GD’, ‘11’, message box appears
of PRODUCT table ’65.500’, because StockPrice's
‘95000’, ‘50’ data type is integer
5 Validation of Enter a value into Data of a new Failure when inputting
input Date column of receipt in data into RECEIPT
RECEIPT table in RECEIPT table: table, an error
mm-dd-yyyy ‘R0010’, ’08-13- message box appears
Action
Test Expected results Date Actual results
taken
1 Failure when inputting 13-08- An error message box appeared: None
data into RECEIPT 2019
table, an error
message box appears
because there is no
Seller ‘S004'
assigned in SELLER
table
Success when
13-08-
8 inputting data into Success when inputting data None
2019
DETAIL table
Failure when inputting An error message box appeared:
data into DETAIL
table, an error
message box appears
13-08-
9 because ReceiptID None
2019
and ProductID
combined are the
primary keys of
DETAIL table
Success when
inputting data into
RECEIPT table, Date Success when inputting data,
13-08-
10 column receives Date column receives default None
2019
default value that is value ‘13-08-2019’
the date of receipt
creation
11 Failure when inputting 13-08- An error message box appeared: None
data into PRODUCT 2019
table, an error
message box appears
because SellPrice has
an constraint that
SellPrice must be
greater than 0
Success when
13-08-
12 inputting data into Success when inputting data None
2019
PRODUCT table
Failure when inputting
data into PRODUCT
table, an error
message box appears
13-08- Recode
13 because different Success when inputting data
2019 & Retest
products must be
different categories or
same category but
different sizes
An error message box appeared:
Failure when inputting
data into PRODUCT
table, an error
message box appears
13-08-
14 because different None
2019
products must be
different categories or
same category but
different sizes
CONCLUSION
However, because of limited knowledge and time, the system was built quite
simple and has not been able to put to use in practice yet. The lack of user-friendly
interface makes it difficult for users to use. Due to no practical experience, this
system is not really complete and there are still many points to be improved to meet
the actual needs of users. During my next study at BTEC, I will work hard to develop
this database into a mature application that can be used in practice.
REFERENCES
REFERENCES 1