This exercise scores Distinction in database programming. This exercise demonstrates how to code a database, database query syntax, and ways to normalize data while developing a system in Microsoft SQL.
Trang 1ASSIGNMENT 1 FRONT SHEET
Unit number and title Unit 04: Database Design & Development
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism I understand that making a false declaration is a form of malpractice
Student’s signature Grading grid
Trang 2 Summative Feedback: Resubmission Feedback:
Signature & Date:
2.1
2.2
Trang 3Table of Contents
A Introduction 6
B Task 1 Statements of user and system requirements 7
1.1 Overview about the Problem 7
1.2 Requirements of the application 7
a Business process 7
b Business rules 7
c Requirements 8
d User story 9
e Objectives (Things intended to achieve) 9
f Output 9
C Task 2 Design the relational database system 12
2.1 Analyse the requirements 12
2.2 Database design with explanations 13
a Logical design(ERD) 13
b ER diagram 17
2.3 Review whether the database is normalized 19
a First Normal Form (1NF) 20
b Second Normal Form (2NF) 20
c Third Normal Form (3NF) 21
d Conclusion 22
Trang 42.4 Data validation 24
2.5 Wireframe of the application 30
2.6 Evaluation 40
a Advantage 40
b Disadvantage 41
c Future development plans 41
D Conclusion 42
E References 42
Trang 5Table of picture
Picture 1: Information of Customer 10
Picture 2: Information of Staff 10
Picture 3: Information of Products 10
Picture 4: Information of Orders 11
Picture 5: Top 5 Customers spend the most in the year 11
Picture 6: Top 5 Products purchased the most in the year 11
Picture 7: Top 5 staffs sell the most in the year 12
Picture 8: Entity-relationship diagram at the conceptual level 17
Picture 9: Complete Entity Relationship Diagram 18
Picture 10: Login interface 31
Picture 11: Main layout 32
Picture 12: Menu of View option 33
Picture 13: Example of View Customer List Layout 34
Picture 14: Menu of add options 35
Picture 15: Example of Add new Staff Layout 36
Picture 16: Menu of Update options 37
Picture 17: Update Customer layout 38
Picture 18: Menu of Statistic options 39
Trang 6A Introduction
We live in a modern society where everything is modern and innovative Every day, there is a lot of innovation, especially in technology When it comes to technology, we must admit that it has permeated every aspect of our lives, from simple devices such as phones and computers to complex programming applications Currently, digital
transformation technology is gaining popular in a variety of disciplines, particularly company management models While offline stores are progressively becoming outdated, online shops are an excellent solution for developing this model
In this assignment, I will discuss relational database, specifically how I design it, detailed explanations of its functions and characteristics, and finally an evaluation of the functions and the design In addition, I created 8 tables in my design to easily manager, and each table has its own function and information to create a manage system for FPT SHOP These tables will help managers enter client information or staffs, products such as address or id, and the program will also help managers determine which consumers purchase the most, which things sell best, and which employees are the best
Trang 7B Task 1 Statements of user and system requirements
1.1 Overview about the Problem
FPT Shop is now experiencing difficulty in processing the database from all of its locations around the country, which is increasing as the number of stores grows which is expanding due to the growth in the number of stores FPT shop approached my firm and requested assistance I decided to create a new database where people may register using their phone number or email address as their ID and place an order Each consumer will be assigned
a caregiver, and each staff will report to their management This will assist FPT Shop in managing all data ranging from staff to customers, as well as new or additional items to the organization As a result, in order to create a new database, I need to understand the needs of consumers, users, and staff while signing into the application and ordering and reviewing items Customer information will also be kept safe and secure, staffs and manager, who will oversee everything to ensure that the application always fulfills the user's requirements
1.2 Requirements of the application
b Business rules
• Customer, staffs, managements, accountants and directors must use a phone number or email account to log in to the application Customers are unable to change their own information or orders
• Staff can view order advice for customers
• The manager can edit the information of the order as well as the customer If customers want to change They will have logged in and place an order will receive an email with a request to amend the information
Trang 8If the request is approved by the management, the client may modify the information or erase it and reinstall a new one (Management has only 24 hours to approve or decline the request)
• The accountant can view the store's sales statistics so that they can be submitted to the management
• The board of directors will look at the statistics of the accounting reports, then apply the reward policy for employees as well as apply discount codes to customers
c Requirements
➢ The database that is developed must fulfill fundamental criteria such as ease of access, storage, management, and updating The system must also assure the database's security At the same time, they must satisfy all of the scenario's criteria
➢ Functional requirements:
• Customer:
o Customers may order products
o After logging in, the customer may examine product information and provide it
o Once the manager accepts that need, the customer can add information to the order product and delete that information
• Staff:
o Employees login app and can access just product and order of client
o Employees can change order status
o Employees can view customer information
• Manager:
o Administrators can accept requests to alter client information
o A manager can manage many staffs and can keep information
o Managers have the ability to regulate product, add product, and delete product
o Managers can also edit or delete information of employees as well as customers
• Product:
o When a valuable product is brought to the store, it must have a distinct brand
Trang 9o Products will be classified into certain categories, with pricing that are competitive in both the domestic and international markets
➢ Non-functional requirements:
All objects will be able to log in using their FPT username and password in 20 minutes
The web can be accessed by up to 500 users at once
It takes less than 3 seconds for the web to respond
d User story
• As a Customer, I want to buy quality products on the app and have it delivered to my door to save time So that I don't have to wait in line and wait at the store Everything on the app is very clear like name, price, quality
• As a Staff, I want to see product information, customer information, orders So I logged in to the app to get information for consulting and care customer
• As a Manager of FPT shop, I want to edit the information’s products So that I logged into the system to check Everything on the app is very clear like product's name, brands, categories, total price
• As an accountant, I want to see product information, the number of products in stock So that I can control revenue of shop
• As an accountant, I want to see the store's sales statistics So that I logged into the system to check from which to apply the reward policy for employees
e Objectives (Things intended to achieve)
The database must provide adequate functions, such as viewing, adding, removing, and updating data, as well
as allowing users to quickly and easily access it, and it must also be safe
f Output
The output to the system will be the data of information of products, staffs, and customers, etc
Trang 10Picture 1: Information of Customer
Picture 2: Information of Staff
Picture 3: Information of Products
Trang 11Picture 4: Information of Orders
Picture 5: Top 5 Customers spend the most in the year
Picture 6: Top 5 Products purchased the most in the year
Trang 12Picture 7: Top 5 staffs sell the most in the year
C Task 2 Design the relational database system
2.1 Analyse the requirements
• Management, staff, retailers, and customers all utilize the app for different reasons, but the unifying goal is to deliver things to customers This system protects client or order information to avoid theft and invasion of privacy, so
customers may feel secure when shopping on the system If the client wishes to change the information or order, the manager's approval is necessary Managers can also see customer and order data The consumer can place several things in an order and the staff will always update the order status for the buyer to trust
• I utilize the Microsoft SQL Server database to plan a database based on the company's requirements There are 8 tables in my database, separated parts into sales and productions, each containing different functions to suit the requirements of the FPT shop Tables include:
o About sales:
✓ Customers: Holds complete client information such as ID, name, address, phone number, and so on
✓ Staffs: provides complete employee information such as ID, name, and address, manager
✓ Orders: including order date, shipped date, order status
✓ OrderItems: includes information such as the number of goods and the customer's total purchase amount
Trang 13✓ Discounts: includes time-limited discount codes
o About productions:
✓ Products: displays all info associated with the product
✓ Categories table: used to display all product categories to assist FPT Shop in controlling and following consumers
✓ Brands: contains brands associated with each FPT store goods
2.2 Database design with explanations
a Logical design(ERD)
Identify relationships:
Identify and associate attributes with entities
Trang 14Staffs entity
6 PhoneNumber Contains staff’s number phone
Primary key: StaffId, Foreign key: ManageId
Orders entity
2 CreateDate Contains order’s created date
3 RequireDate Contains order’s required date
4 ShippedDate Contains order’s shipped date
Primary key: OrderId, Foreign key: CustomerId, StaffId, OrderItemId
Trang 15OrderItems entity
Primary key: OrderItemId, Foreign key: OrderId, ProductId, DiscountId
Discounts entity
2 DiscountName Contains name’s discount
6 DiscountPercent Contains percent discount
7 DiscountAmount Contains reduction amount
Primary key: DiscountId
Trang 16Products entity
Primary key: ProductId, Foreign key: BrandId, CategoryId
Brands entity
Primary key: BrandId
Categories entity
Primary key: CategoryId
Trang 17b ER diagram
Picture 8: Entity-relationship diagram at the conceptual level
Trang 18Picture 9: Complete Entity Relationship Diagram
Trang 19• Description of the ER diagram: The diagram above has 8 entities that are related to one another, with the OrderItems entity being distinct from the link between the two segments sales and productions The above entities all have the attributes listed above
• There are 8 relationships between 8 entities:
o Customer and Orders (1 - m): 1 customer can place multiple orders but those orders can only be ordered by 1 customer
o Staff and Orders :(1 - m) 1 staff can create multiple orders but those orders can only be created by 1 staff
o Staffs and Staffs (1-m): 1 manager can manage many employees but the employees can only be managed by 1 manager
o Orders and OrderItems (1 - m): An orders can belong to more than 1 items of order items if the orders contains more than 1 products, but each items in the order items is only related to one order
o Discount and OrderItems(1-m): 1 discount code can be applied to multiple items but 1 item can only contain 1 discount code
o Product and OrderItems(1-m): 1 product can have multiple items but those items can only be selected by 1 product
o Brands and Products(1-m): 1 brand can have multiple products but those products can only be contained by 1 brand
o Categories and Products(1-m): 1 category can have multiple products but those products can only be had by 1 category
2.3 Review whether the database is normalized
• Database normalization is a method for structuring data in a database Normalization is a method of dissecting tables in a systematic way to minimize data redundancy (repetition) and undesired features such as Insertion, Updating, and Deletion Anomalies It is a multi-step method that converts data into tabular format while deleting duplicates from relation tables (Anon, n, d)
• Normalization is mostly used to eliminate duplicate (useless) data
Trang 20• Assuring that data dependencies make sense, i.e that data is stored properly
• Common types of data normalization:
a First Normal Form (1NF)
o To be in the First Normal Form, a table must meet the four conditions outlined below:
▪ It should only contain attributes/columns with single (atomic) values
▪ Column values should be from the same domain
▪ A table's columns should all have distinct names
▪ And the sequence in which data is stored is irrelevant
o Example:
✓ The Staff table is not in 1st normal form because it contains the multivalued attribute PhoneNumber column:
StaffId Name Status Email PhoneNumber
1 Trần Đức Long Working dlong@gmail.com 0327268237,
0945848855
2 Nguyễn Tiến Đạt Working tiendat@gmail.com 0912552226
3 Nguyễn Vân Ly Working lynguyen@gmail.com 0976123123,
0902123123
✓ To return the above table to 1NF, we separate each value into a row as follows:
StaffId Name Status Email PhoneNumber
1 Trần Đức Long Working dlong@gmail.com 0327268237
1 Trần Đức Long Working dlong@gmail.com 0945848855
2 Nguyễn Tiến Đạt Working tiendat@gmail.com 0912552226
3 Nguyễn Vân Ly Working lynguyen@gmail.com 0976123123
3 Nguyễn Vân Ly Working lynguyen@gmail.com 0902123123
b Second Normal Form (2NF)
o In order for a table to be in Second Normal Form,
▪ It must be written in the 1NF
Trang 21▪ Each non-key attribute must totally rely on the key property in order to operate
o Example:
✓ In the following example, we have a Customers table that is not in 2NF because it stores both product information, product names do not depend on the primary key of the Customers table
CustomerId Name Address PhoneNumber Products
✓ Therefore, we separate the Product that each Customers buys into a separate table to meet the 2NF standard Customers table:
CustomerId Name Address PhoneNumber
c Third Normal Form (3NF)
o When a table is in the Third Normal Form, it means that,
▪ It's written in the Second Normal form
▪ It doesn't have transitive partial dependencies
o Example: