1. Trang chủ
  2. » Công Nghệ Thông Tin

Assignment 2 Database Design Development (1622 Distinction)

44 4 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Database Design & Development
Tác giả Bui Quang Minh
Người hướng dẫn Ho Van Phi
Trường học tec
Chuyên ngành computing
Thể loại assignment
Năm xuất bản 2023
Định dạng
Số trang 44
Dung lượng 4,15 MB

Cấu trúc

  • CHAPTER 1: STATEMENTS OF USER AND SYSTEM REQUIREMENTS (P1) (6)
    • I. OVERVIEW (6)
      • 1. Introduction of proposed system (6)
      • 2. Analysing current system (6)
      • 3. Evaluating current system (7)
      • 4. Proposal of new system (8)
    • II. APPLICATION REQUIREMENT (8)
      • 1. Hardware requirement (8)
      • 2. Software requirement (8)
  • CHAPTER 2: DESIGN THE RELATIONAL DATABASE SYSTEM (P1-D1) (9)
    • I. ANALYSING REQUIREMENTS (0)
    • II. DATABASE DESING with EXPLAINATIONS (0)
    • III. REVIEW IF DATABASE IS NORMALIZED (10)
    • IV. DATA VALIDATION (11)
      • 1. Products table (11)
      • 2. Customers table (11)
      • 3. Staffs table (12)
      • 4. Orders table (12)
      • 5. Details table (13)
      • 6. Suppliers table (13)
    • V. WIREFRAME OF APPLICATION (14)
      • 1. Creating tables using tool (14)
      • 2. Creating tables using command (15)
      • 3. Database diagram (17)
      • 4. Sample data (17)
        • 4.1 Sample data of CUSTOMERS table (17)
        • 4.2 Sample data of STAFFS table (18)
        • 4.3 Sample data of PRODUCTS table (19)
        • 4.4 Sample data of ORDERS table (20)
        • 4.5 Sample data of DETAILS table (20)
        • 4.6 Sample data of SUPPLIERS table (21)
      • 5. Query (22)
        • 5.1 Query to show products from 10m to 20m (22)
        • 5.2 Query to show income of order at a date (22)
        • 5.3 Query to show income of all order (22)
      • 6. View tables (23)
        • 6.1 View to managing products (23)
        • 6.2 View of available products (23)
    • VI. Assess the effectiveness of the design (0)
  • CHAPTER 4: DEVELOP DATABASE SYSTEM (P2-P3) (25)
    • I. DATABASE DIAGRAM (25)
    • II. DATA VALIDATION (25)
      • 1. PRODUCTS table (25)
      • 2. CUSTOMERS table (26)
      • 3. STAFFS table (26)
      • 4. ORDERS table (26)
      • 5. DETAILS table (27)
      • 6. SUPPLIERS table (27)
    • III. QUERYING ACROSS MULTIPLE TABLES (27)
      • 1. Print orders’ list of customerID ‘0100’ (27)
      • 2. Show income of order at a date (28)
      • 3. Show income of all orders (28)
  • CHAPTER 5: PRODUCE QUERIES (P3-M2-M3) (29)
    • I. IMPLEMENT QUERY LANGUAGE (P3) (29)
    • II. IMPLEMENT FULLY FUNCTIONAL DATABASE (M2) (32)
      • 1. View of PRODUCTS table (0)
      • 2. View of CUSTOMERS table (0)
      • 3. View of STAFFS table (0)
      • 4. View of ORDERS table (0)
      • 5. View of DETAILS table (0)
      • 6. View of SUPPLIERS table (0)
    • II. ADVANCED VIEWS (M3) (0)
      • 1. View of revenue ragarding year (34)
      • 2. View of revenue ragarding Products (35)
      • 3. View of revenue made from staffs (35)
      • 4. View of orders placed by customers (0)
      • 5. View of orders number made by staffs (0)
  • CHAPTER 6: TEST SYSTEM (P4-M4) (37)
    • I. TEST SYSTEM (37)
      • 1. Test cases (37)
      • 2. Test logs (38)

Nội dung

Mục đích của môn học này là mang đến cho sinh viên cơ hội phát triển sự hiểu biết về các khái niệm và vấn đề liên quan đến thiết kế và phát triển cơ sở dữ liệu, cũng như cung cấp các kỹ năng thực tế để chuyển sự hiểu biết đó vào việc thiết kế và tạo ra các cơ sở dữ liệu phức tạp. Các chủ đề trong phần này là: kiểm tra các công cụ và kỹ thuật thiết kế khác nhau; kiểm tra các lựa chọn phần mềm phát triển khác nhau; xem xét các tính năng phát triển của một giải pháp mạnh mẽ đầy đủ chức năng bao gồm tính toàn vẹn dữ liệu, xác thực dữ liệu, tính nhất quán của dữ liệu, bảo mật dữ liệu và các phương tiện truy vấn cơ sở dữ liệu nâng cao trên nhiều bảng; giao diện người dùng thích hợp cho cơ sở dữ liệu và cho các hệ thống liên kết bên ngoài khác; tạo các báo cáotrang tổng quan phức tạp, kiểm tra hệ thống theo yêu cầu của người dùng và hệ thống; và các thành phần của tài liệu hệ thống hoàn chỉnh

STATEMENTS OF USER AND SYSTEM REQUIREMENTS (P1)

OVERVIEW

FPT Shop has contacted my firm where I am working as a Database developer because the increasing number of stores FPT Shop are having many challenges that it has to handle throughout the nation It has made decision to create a new database with many purposes with different objects such as users can sign in with phone numbers and other data, supervisors can manage their stores and director board can view all information from all stores

The FPT Shop currently stores all data in excel files when a customer purchases an item, a staff will write that item’s information into a particular paper called receipt and give it to the customer All available items and purchased items also store in excel files

Figure 1 Product table’s data in excel

After a day, month, or year, staff will create a new table to calculate the total amount of money earned and reckon up the quantity, the following table made in excel:

 Spreadsheets can be more collaborative than other tools

 It’s easy to manipulate and analyze data

 You can integrate spreadsheets with specific tools

 Spreadsheets are quick and easy to add to a workflow

 Spreadsheets are fantastic tools for financial documents

 You have access to countless spreadsheet templates

 It’s hard to tell who edited the spreadsheet

 There will be multiple versions of the truth

 Critical customer data is at everyday life's mercy

 There’s no native integration with business systems

 Spreadsheets make it harder for managers to manage team members

By creating a relational database system for the shop and organizing the information that has to be maintained into precise and understandable tables, the above issues may be resolved for the following benefits:

 Reduced costs of data entry, data storage, and data retrieval

 Improved data access using host and query languages

 Higher data integrity from application programs

APPLICATION REQUIREMENT

 SQL Server requires a minimum of 6 GB of available hard-disk space

 SQL Server requires Super-VGA (800x600) or higher resolution monitor

 Minimum operating systems includes minimum NET framework.

DESIGN THE RELATIONAL DATABASE SYSTEM (P1-D1)

REVIEW IF DATABASE IS NORMALIZED

From ERD Diagram shown above, we can see that the Products table contains transitive functional Dependence so that it cannot achieve 3NF (The third normal form):

To achieve 3NF, attribute ‘SupplierName’ needs to split from PRODUCTS in order to combine with SupplierID and then create a new table named SUPPLIERS

As the result, after normalizing, the database system contains the following tables

1 Products (ProductID, ProductName, Price, Quantity, SupplierID)

2 Orders (OrderID, OrderDate, CustomerID, StaffID)

3 Customers (CustomerID, CustomerName, Address, PhoneNumber)

4 Staffs (StaffID, StaffName, Address, Salary)

5 Details (OrderID, ProductID, Price, Quantity)

DATA VALIDATION

Products Table: this table is used to store all information about products It has several columns such as ProductID, ProductName, Price, Quantity… Among these, productID is the primary key The column productName must be not null and the Price, Quantity must be bigger than zero (>0) The detail of the table Products is shown as follow:

Column name Data Tye Allow null Contraint

Price Int Yes Check (Price>0)

Quantity Int Yes Check (quantity>0)

SupplierID Nvarchar(10) No FK (Suppliers)

Customers Table: this table is used to store all information of customers It has several columns such as CustomerID, CName, Address, PhoneNum… Among these, CustomerID is the primary key The columns CName and Address must not be null The detail of the table Customers is shown as follows:

Column name Data Tye Allow null Contraint

Staffs Table: this table is used to store all information about staff It has several columns such as StaffID, SName, Address, Salary… Among these, StaffID is the primary key The columns SName and Address must not be null and and Salary must be bigger than zero (>0) The detail of the table Staffs is shown as follows:

Column name Data Tye Allow null Contraint

Salary Int Yes Check (Salary>0)

Orders Table: this table is used to store all information on orders It has several columns such as OrderID, OrderDate, CustomerID, StaffID… Among these, StaffID is the primary key The columns' OrderDate must not be null The detail of table Orders is shown as follows:

Column name Data Tye Allow null Contraint

CustomerID Nvarchar(10) No FK from Customers

StaffID Nvarchar(10) No FK from Staffs

Details Table: this table is used to store all information of all details It has several columns such as OrderID, ProductID, Price, Quantity… Among these, OrderID and ProductID are the primary keys and the Price, Quantity must be bigger than zero (>0) The detail of table Details is shown as follows:

Column name Data Tye Allow null Contraint

OrderID Nvarchar(10) No PK-FK from Orders

ProductID Nvarchar(10) No PK-FK from Products

Price Int No Check (Price>0)

Quantity Int No Check (quantity>0)

Suppliers Table: this table is used to store all information of all suppliers It has two columns including SupplierID and SupplierName Among these, SupplierID is the primary keys The detail of table Suppliers is shown as follows:

Column name Data Tye Allow null Contraint

WIREFRAME OF APPLICATION

ProductID NVARCHAR(10) PRIMARY KEY, PName NVARCHAR(50) NOT NULL UNIQUE, Price INT CHECK(Price>0),

Quantity INT CHECK(Quantity>0) SupplierID nvarchar(10) REFERENCES SUPPLIERS (SupplierID) )

Figure 10 Products table using command

CustomerID NVARCHAR(10) PRIMARY KEY, CName NVARCHAR(100) NOT NULL,

Address NVARCHAR (150) NOT NULL, PhoneNum NVARCHAR (11)

Figure 11 Customers table using command

StaffID NVARCHAR(10) PRIMARY KEY, SName NVARCHAR(100) NOT NULL, Address NVARCHAR (150) NOT NULL, Salary INT CHECK(Salary>0) )

Figure 12 Staffs table using command

OrderID NVARCHAR(10) PRIMARY KEY, OrderDate DATE NOT NULL,

CustomerID NVARCHAR(10) REFERENCES CUSTOMERS (CustomerID), StaffID NVARCHAR(10) REFERENCES STAFFS (StaffID)

Figure 13 Orders table using command

Figure 14 Details table using command

Figure 15 Suppliers table using command

OrderID NVARCHAR(10) REFERENCES ORDERS (OrderID), ProductID NVARCHAR(10) REFERENCES PRODUCTS (ProductID), Price INT CHECK(Price>0),

Quantity INT CHECK(Quantity>0) CONSTRAINT PK_DETAIL PRIMARY KEY (OrderID, ProductID) )

SupplierID nvarchar(10) PRIMARY KEY, SupplierName nvarchar(50)

4.1 Sample data of Customers table

INSERT INTO DBO.CUSTOMERS VALUES ('0100', N'Bùi Quang Tường', N'11 Ngô Quyền',

GO INSERT INTO DBO.CUSTOMERS VALUES ('0101', N'Bùi Thị Thu tuyền', N'50 Ngô Quyền',

GO INSERT INTO DBO.CUSTOMERS VALUES ('0102', N'Huỳnh Văn Tú', N'122 Nguyễn Trưng',

GO INSERT INTO DBO.CUSTOMERS VALUES ('0103', N'Nguyễn Thị Anh', N'59 Trần Phú',

GO INSERT INTO DBO.CUSTOMERS VALUES ('0104', N'Lê Bá Lộc', N'25 Trần Phú', '0706162561') GO

4.2 Sample data of staff table

INSERT INTO DBO.STAFFS VALUES ('1123', N'Bùi Quang Minh', N'78 Lê Tấn Trung', 23000000)

GO INSERT INTO DBO.STAFFS VALUES ('2123', N'Trần Thị Thu Hà', N'50 Nam Thọ', 15000000)

INSERT INTO DBO.STAFFS VALUES ('3123', N'Hoàng Văn Nam', N'60 Lê Duẩn', 17000000)

INSERT INTO DBO.STAFFS VALUES ('1223', N'Phạm Thị Đài Trang', N'80 Lê Tấn

INSERT INTO DBO.STAFFS VALUES ('2223', N'Phan Tuyết Nhung', N'77 Lê Đức Thọ', 5000000) GO

4.3 Sample data of Products table

INSERT INTO DBO.PRODUCTs VALUES ('IP14', 'Iphone 14', 23000000, 10, 'APP')

GO INSERT INTO DBO.PRODUCTs VALUES ('IP14PM', 'Iphone 14 Pro Max', 36000000, 25, 'APP')

INSERT INTO DBO.PRODUCTs VALUES ('IP13', 'Iphone 13', 18400000, 55, 'APP')

INSERT INTO DBO.PRODUCTs VALUES ('IP13M', 'Iphone 13 Mini', 25200000, 5, 'APP')

GO INSERT INTO DBO.PRODUCTs VALUES ('GZFlip4', 'Galaxy Z Flip4', 32400000, 2, 'SS')

INSERT INTO DBO.PRODUCTs VALUES ('GZFold4', 'Galaxy Z Fold4', 55600000, 7, 'SS')

INSERT INTO DBO.PRODUCTs VALUES ('RN12', 'Redmi Note 12', 11000000, 40, 'Mi')

GO INSERT INTO DBO.PRODUCTs VALUES ('RN12P', 'Redmi Note 12 Pro', 14260000, 45, 'Mi')

INSERT INTO DBO.PRODUCTs VALUES ('OR8P', 'Oppo Reno 8 Pro', 1900000, 45, 'OPP')

INSERT INTO DBO.PRODUCTs VALUES ('Vv23', 'Vivo V23', 9990000, 45, 'Vi')

Figure 19 Data of all products

4.4 Sample data of Orders table

INSERT INTO DBO.ORDERS VALUES ('111', '2023-01-1', '0100', '2123')

GO INSERT INTO DBO.ORDERS VALUES ('112', '2023-01-2', '0101', '3123')

INSERT INTO DBO.ORDERS VALUES ('113', '2022-12-30', '0103', '2223')

INSERT INTO DBO.ORDERS VALUES ('114', '2022-12-25', '0104', '2223')

GO INSERT INTO DBO.ORDERS VALUES ('115', '2022-11-1', '0104', '1223')

INSERT INTO DBO.ORDERS VALUES ('116', '2022-10-17', '0102', '2123')

Figure 20 Data of orders placed

4.5 Sample data of Details table

INSERT INTO DBO.DETAILS VALUES ('111', 'IP14', 23000000, 5)

GO INSERT INTO DBO.DETAILS VALUES ('112', 'IP13M', 25200000, 7)

INSERT INTO DBO.DETAILS VALUES ('113', 'OR8P', 1900000, 12)

INSERT INTO DBO.DETAILS VALUES ('114', 'RN12P', 14260000, 17)

GO INSERT INTO DBO.DETAILS VALUES ('115', 'Vv23', 9990000, 20)

INSERT INTO DBO.DETAILS VALUES ('116', 'GZFold4', 55600000, 2)

Figure 21 Data of orders’ details

4.6 Sample data of Suppliers table

INSERT INTO DBO.SUPPLIERS VALUES ('APP', 'Apple')

GO INSERT INTO DBO.SUPPLIERS VALUES ('SS', 'SamSung')

GO INSERT INTO DBO.SUPPLIERS VALUES ('Mi', 'Xiaomi')

GO INSERT INTO DBO.SUPPLIERS VALUES ('OPP', 'OPPO')

GO INSERT INTO DBO.SUPPLIERS VALUES ('Vi', 'Vivo') GO

5.1 Query to show products from 10m to 20m

SELECT * FROM PRODUCTS WHERE PRODUCTs.Price >= 10000000 and Price 0)

Quantity Int Yes Check (quantity>0)

SupplierID Nvarchar(10) No FK (Suppliers)

DEVELOP DATABASE SYSTEM (P2-P3)

DATABASE DIAGRAM

DATA VALIDATION

Column name Data Tye Allow null Contraint

Price Int Yes Check (Price>0)

Quantity Int Yes Check (quantity>0)

SupplierID Nvarchar(10) No FK (Suppliers)

Column name Data Tye Allow null Contraint

Column name Data Tye Allow null Contraint

Salary Int Yes Check (Salary>0)

Column name Data Tye Allow null Contraint

CustomerID Nvarchar(10) No FK from Customers

StaffID Nvarchar(10) No FK from Staffs

Column name Data Tye Allow null Contraint

OrderID Nvarchar(10) No PK-FK from Orders

ProductID Nvarchar(10) No PK-FK from Products

Price Int No Check (Price>0)

Quantity Int No Check (quantity>0)

Column name Data Tye Allow null Contraint

QUERYING ACROSS MULTIPLE TABLES

1 Print orders’ list of customerID ‘0100’

SELECT CUSTOMERS.CustomerID, CName, OrderDate, ProductID, Quantity, Price,

FROM CUSTOMERS INNER JOIN ORDERS ON ORDERS.CustomerID = CUSTOMERS.CustomerID

INNER JOIN DETAILS ON DETAILS.OrderID = ORDERS.OrderID where CUSTOMERS.CustomerID = '0100'

Figure 30 Query to show orders’ list of specific customer

2 Show income of order at a date

SELECT ORDERS.OrderID, CUSTOMERS.CName, P.PName, DETAILS.Quantity, DETAILS.Price, DETAILS.Quantity * DETAILS.Price AS N'Thành tiền'

FROM ORDERS INNER JOIN DETAILS ON ORDERS.OrderID = DETAILS.OrderID

INNER JOIN CUSTOMERS ON ORDERS.CustomerID = CUSTOMERS.CustomerID INNER JOIN PRODUCTs P ON P.ProductID = DETAILS.ProductID

Figure 31 Query to show income of order at a date

3 Show income of all orders

SELECT ORDERS.OrderID, CUSTOMERS.CName, P.PName, DETAILS.Quantity, DETAILS.Price, DETAILS.Quantity * DETAILS.Price AS N'Thành tiền'

FROM ORDERS INNER JOIN DETAILS ON ORDERS.OrderID = DETAILS.OrderID

INNER JOIN CUSTOMERS ON ORDERS.CustomerID = CUSTOMERS.CustomerID INNER JOIN PRODUCTs P ON P.ProductID = DETAILS.ProductID

Figure 32 Query to show income of all orders

PRODUCE QUERIES (P3-M2-M3)

IMPLEMENT QUERY LANGUAGE (P3)

INSERT INTO DBO.PRODUCTs VALUES ('IP14', 'Iphone 14', 23000000, 10, 'APP')

GO INSERT INTO DBO.PRODUCTs VALUES ('IP14PM', 'Iphone 14 Pro Max', 36000000, 25, 'APP')

INSERT INTO DBO.PRODUCTs VALUES ('IP13', 'Iphone 13', 18400000, 55, 'APP')

INSERT INTO DBO.PRODUCTs VALUES ('IP13M', 'Iphone 13 Mini', 25200000, 5, 'APP')

UPDATE PRODUCTS SET Quantity = 4 WHERE ProductID = 'GZFlip4'

DELETE FROM PRODUCTS WHERE ProductID = 'GZFlip4'

INSERT INTO DBO.CUSTOMERS VALUES ('0100', N'Bùi Quang Tường', N'11 Ngô Quyền', '0905905716')

INSERT INTO DBO.CUSTOMERS VALUES ('0101', N'Bùi Thị Thu tuyền', N'50 Ngô Quyền', '0859454746')

INSERT INTO DBO.CUSTOMERS VALUES ('0102', N'Huỳnh Văn Tú', N'122 Nguyễn Trưng', '0122616888')

UPDATE CUSTOMERS SET PhoneNum = '0905905718' WHERE CustomerID = '0100'

DELETE FROM CUSTOMERS WHERE CustomerID = '0100'

INSERT INTO DBO.STAFFS VALUES ('1123', N'Bùi Quang Minh', N'78 Lê Tấn Trung', 23000000)

INSERT INTO DBO.STAFFS VALUES ('2123', N'Trần Thị Thu Hà', N'50 Nam Thọ', 15000000)

INSERT INTO DBO.STAFFS VALUES ('3123', N'Hoàng Văn Nam', N'60 Lê Duẩn', 17000000)

UPDATE STAFFS SET Salary = 24000000 WHERE StaffID = '1123'

DELETE FROM STAFFS WHERE StaffID = '1123'

INSERT INTO DBO.ORDERS VALUES ('111', '2023-01-1', '0100', '2123')

INSERT INTO DBO.ORDERS VALUES ('112', '2023-01-2', '0101', '3123')

INSERT INTO DBO.ORDERS VALUES ('113', '2022-12-30', '0103', '2223')

UPDATE ORDERS SET OrderDate = '2023-01-15' WHERE OrderID = '111'

DELETE FROM ORDERS WHERE OrderID = '111'

INSERT INTO DBO.DETAILS VALUES ('111', 'IP14', 23000000, 5)

GO INSERT INTO DBO.DETAILS VALUES ('112', 'IP13M', 25200000, 7)

GO INSERT INTO DBO.DETAILS VALUES ('113', 'OR8P', 1900000, 12)

UPDATE DETAILS SET Quantity = 7 WHERE OrderID = '111'

DELETE FROM DETAILS WHERE OrderID = '111'

INSERT INTO DBO.SUPPLIERS VALUES ('APP', 'Apple')

GO INSERT INTO DBO.SUPPLIERS VALUES ('SS', 'SamSung')

GO INSERT INTO DBO.SUPPLIERS VALUES ('Mi', 'Xiaomi')

UPDATE SUPPLIERS SET SupplierName = 'AppleP' WHERE SupplierID = 'APP'

DELETE FROM SUPPLIERS WHERE SupplierID = 'APP'

IMPLEMENT FULLY FUNCTIONAL DATABASE (M2)

CREATE VIEW View_Products AS SELECT * FROM PRODUCTS

Figure 33 View of PRODUCTS table

CREATE VIEW View_Customers AS SELECT * FROM CUSTOMERS

Figure 34 View of CUSTOMERS table

CREATE VIEW View_Staffs AS SELECT * FROM STAFFS

Figure 35 View of STAFFS table

CREATE VIEW View_Orders AS SELECT * FROM ORDERS

Figure 36 View of ORDERS table

CREATE VIEW View_Details AS SELECT * FROM DETAILS

Figure 37 View of DETAILS table

ADVANCED VIEWS (M3)

CREATE VIEW View_Suppliers AS SELECT * FROM SUPPLIERS

Figure 38 View of SUPPLIERS table

1 View of revenue ragarding year

The FPT shop needs to manage the income regarding year such as 2022 or 2023, they want to supervise the revenue to pay salary for staffs and supplies The following view is used to show income depending on year the manager wants

SELECT ORDERS.OrderID, CUSTOMERS.CName, P.PName, DETAILS.Quantity,

DETAILS.Price, DETAILS.Quantity * DETAILS.Price AS N'Revenue'

FROM ORDERS INNER JOIN DETAILS ON ORDERS.OrderID = DETAILS.OrderID

INNER JOIN CUSTOMERS ON ORDERS.CustomerID = CUSTOMERS.CustomerID INNER JOIN PRODUCTs P ON P.ProductID = DETAILS.ProductID

Figure 39 View of revenue regarding year

2 View of revenue ragarding Products

The FPT shop needs to manage the income regarding products For example, how much money earned from selling iphone 14 They want to supervise the revenue from products and thanks to that they can know that which product is more popular The following view is used to show the money earned from particular product

SELECT DETAILS.ProductID, PRODUCTs.PName, SUM(DETAILS.Quantity) AS

'Quantity', SUM(DETAILS.Quantity * DETAILS.Price) AS 'Revenue'

From DETAILS INNER JOIN PRODUCTS ON PRODUCTs.ProductID = DETAILS.ProductID GROUP BY DETAILS.ProductID, PRODUCTs.PName

Figure 40 View of revenye regarding products

3 View of revenue made from staffs

The FPT shop needs to know and manage the income every single staff has made so that the manager can know and give the bonus for excellent staff The following view is used to manage the income that staff made

SELECT S.StaffID, S.SName, SUM(D.Quantity * D.Price) as 'Revenue'

INNER JOIN ORDERS O ON O.StaffID = S.StaffID

INNER JOIN DETAILS D ON D.OrderID = O.OrderID

Figure 41 View of revenue made from staff

TEST SYSTEM (P4-M4)

TEST SYSTEM

Test What is being tested How Test data used Expected results

1 Validation of input Enter a value that beyond the limit of PhoneNum in CUSTOMERS table

Failure when entering the phoneNum, an error message box pops up because the limit of phoneNum is 11

2 Allowing null Enter full collumn but empty

‘Address’ collumn which is not allowed null in CUSTOMERS table

‘090999777 and enter nothing in Address collumn

Failure when not entering the Address, an error message box pops up because the ‘Address’ collumn is not allowed null

3 Validation of input Enter a string into a collumn that has to enter int value – collumn price in PRODUCTS table

‘GZFold5’ ‘Galaxy Z Fold 5’ ‘55’ ‘SS’ and in price collumn, I enter ‘Việt Nam’ instead of a number

Failure when entering the Price, an error message box pops up because the ‘Price’ collumn needs to be input a number

4 Validation of input Enter a string into a collumn that has to enter int value – collumn quantity in PRODUCTS table

‘GZFold5’ ‘Galaxy Z Fold 5’ ‘777000’ ‘SS’ and in quantity collumn, I enter

‘năm lăm’ instead of a number

Failure when entering the Quantity, an error message box pops up because the ‘Quantity collumn needs to be input a number

5 Validation of input Enter a date to

Price collumn which required a number in DETAILS table

‘IP14’ ‘5’ and the quantity is ‘2022-01- 22’ instead of a number

Failure when entering the Price, an error message box pops up because the ‘Price collumn needs to be input a number, not a date

Test What is being tested

How Test data used Expected results Date Actual result Action taken

Enter a value that beyond the limit of PhoneNum in CUSTOMERS table

‘0709999123466’ Failure when entering the phoneNum, an error message box pops up because the limit of phoneNum is 11

22/02 An error message box pops up Enter again until correct

2 Allowing null Enter full collumn but empty

‘Address’ collumn which is not allowed null in CUSTOMERS table

Entering nothing in Address collumn

Failure when not entering the Address, an error message box pops up because the

‘Address’ collumn is not allowed null

22/02 An error message box pops up Enter again until correct

3 Validation of input Enter a string into a collumn that has to enter int value – collumn price in PRODUCTS table

Entering ‘Việt Nam’ instead of a number

Failure when entering the Price, an error message box pops up because the ‘Price’ collumn needs to be input a number

22/02 An error message box pops up Enter again until correct

4 Validation of input Enter a string into a collumn that has to enter int value – collumn quantity in PRODUCTS table

Enter ‘năm lăm’ instead of a number

Failure when entering the Quantity, an error message box pops up because the

‘Quantity collumn needs to be input a number

22/02 An error message box pops up Enter again until correct

5 Validation of input Enter a date to Price collumn which required a number in DETAILS table

Failure when entering the Price, an error message box pops up because the ‘Price collumn needs to be input a number, not a date

22/02 An error message box pops up Enter again until correct

III PRODUCE TECHNICAL and USER DOCUMENTATION (P5)

Going into the main website to download the sql server

Link download SQL Server Developer 2017 https://www.microsoft.com/en-us/sql-server/sql-server-downloads

When you turn the application, there is a window that pops up on your screen, you click connect to connect to the database

Figure 46 Interface of sql server when starting

Firstly, you have to create a database and then use ‘USE” to utilize the database

Figure 47 Query of create database

Secondly, you have to create every single table to save your data onto These are 2 ways to create a table – using query and using design

You create tables regarding order like this SUPPLIERS  STAFFS  CUSTOMERS PRODUCTS

Figure 35 Creating table by design

Figure 48 Creating table using query

You can use ‘insert into’ to insert the new data into the table created before, and then if you want to modify or delete any you can follow the next step below

Figure 49 Query to insert data

You can use ‘update’ or ‘delete’ to update your data if the data on that table is incorrect or delete any collumn or data which is not correct

Figure 50 Query to update and delete data

Using views will have many benefits so that you also should know how to create a view

Firstly, the following will show you how to create a simple view to manage

CREATE VIEW View_Suppliers AS SELECT * FROM SUPPLIERS

Figure 51 View of SUPPLIERS table

If you know creating the simple view, you should learn how to create a complex view, this is an example

SELECT S.StaffID, S.SName, SUM(D.Quantity) AS 'Total number of orders' FROM STAFFS AS S

INNER JOIN ORDERS O ON O.StaffID = S.StaffID

INNER JOIN DETAILS D ON D.OrderID = O.OrderID

Figure 52 View of orders number made by staff

When you finish doing above steps, you should save your file to backup and save data entered

Figure 53 Interface when saving file

To make sure that your file has been saved, go to the folder in PC to check one more time

Figure 54 Interface of folder containing file

Ngày đăng: 02/02/2024, 10:02

TỪ KHÓA LIÊN QUAN

w