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

As2-1622.Pdf

43 15 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

Database Design and Development

Higher Nationals in Computing Database Design and Development ASSIGNMENT No.2 Learner’s name: PHAM NGUYEN QUYNH NHU Assessor name: NGUYEN VAN SON Class: .GCS1005A .… Learner’s ID: .GCS210018 Subject’s ID: 1622 Assignment due: Assignment submitted: ASSIGNMENT FRONT SHEET Qualification TEC Level HND Diploma in Computing Unit number and title Unit 04: Database Design & Development Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Pham Nguyen Quynh Nhu Student ID GCS210018 Class GCS1005A Assessor name Nguyen Van Son 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 Nhu Student’s signature Grading grid P2 P3 P4 P5 M2 M3 M4 M5 D2 D3 ❒ Summative Feedback: Grade: Signature & Date: ❒ Resubmission Feedback: Assessor Signature: Date: Assignment Brief (RQF) Higher National Certificate/Diploma in Computing Student Name/ID Number: Pham Nguyen Quynh Nhu (GCS210018) Unit Number and Title: Unit 04: Database Design & Development Academic Year: 2022 Unit Assessor: Nguyen Van Son Assignment Title: Database implementation and Testing Issue Date: 23 Oct 22 Submission Date: Internal Verifier Name: Date: Submission Format: Format:  This assignment is an Individual assignment and specifically including documents: (1) sql file of your code and represent your code to your tutor (2) a report document  You must use font Calibri size 12, set number of the pages and use multiple line spacing at 1.3 Margins must be: left: 1.25 cm; right: cm; top: cm and bottom: cm The reference follows Harvard referencing system The recommended word limit is 2.000-2.500 words You will not be penalized for exceeding the total word limit The cover page of the report has to be the Assignment front sheet Submission  Students are compulsory to submit the assignment in due date and in a way requested by the Tutor  The form of submission will be a soft copy posted on http://cms.greenwich.edu.vn/  Remember to convert the word file into PDF file before the submission on CMS Note:  The individual Assignment must be your own work, and not copied by or from another student  If you use ideas, quotes or data (such as diagrams) from books, journals or other sources, you must reference your sources, using the Harvard style  Make sure that you understand and follow the guidelines to avoid plagiarism Failure to comply this requirement will result in a failed assignment Unit Learning Outcomes: 3|Page LO2 Develop a fully functional relational database system, based on an existing system design LO3 Test the system against user and system requirements LO4 Produce technical and user documentation Assignment Brief and Guidance: Assignment scenario You are employed as a Database Developer for a large IT consultancy company The company has been approached by FPT Shop which is expanding due to the growth of the number of stores FPT Shop is currently facing difficulties in dealing with managing the database from all shops on over country It decided to develop a new database so that: users can register with their phone numbers as IDs and order or rate, comment for their bought devices, shop managers can take care for their stores and director board can view all data from all shops You are tasked to select one of those systems to develop database for FPT Shop Your tasks are to:  Work with FPT Shop to find out about current requirements for each system  Analyse the requirements and produce clear statements of user and system requirements  Design a relational database system using appropriate design tools and techniques  Develop a fully functional relational database system, based on an existing system design   Test the system against user and system requirements Produce technical and user documentation Part (Assignment 2) Once the designs have been accepted by your manager you have been asked to: Develop the database system using evidence of user interface, output and data validations and querying across multiple tables You want to include more than just the basics so you will implement a fully functional database system which will include system security and database maintenance features You have decided to implement a query language into the relational database system The developed system will be demonstrated to your manager Your manager has asked you to include in the report: (1) Assessing whether meaningful data has been extracted through the use of query tools to produce appropriate management information (2) Evaluating the effectiveness of the database solution in relation to user and system requirements, and suggest improvements (3) Once the system has been developed, you will test the system and your manager will complete a witness statement indicating how your tests are performing against user and system requirements (4) You will produce a brief report assessing the effectiveness of the testing, including an explanation of the choice of test data used (5) Lastly you will produce technical and user documentation which will be given to the company You want to provide some graphical representations for ease of reference in the technical guide, so you have decided to produce a technical and user documentation for a fully functional system, including diagrams showing movement of data through the system, and flowcharts describing how the system works 4|Page Learning Outcomes and Assessment Criteria (Assignment 2): Learning Outcome Pass Merit Distinction LO2 P2 Develop the database system with evidence of user interface, output and data validations, and querying across multiple tables M2 Implement a fully functional database system which includes system security and database maintenance D2 Evaluate the effectiveness of the database solution in relation to user and system requirements, and suggest improvements P3 Implement a query language into the relational database system LO3 P4 Test the system against user and system requirements LO4 P5 Produce technical and user documentation M3 Assess whether meaningful data has been extracted through the use of query tools to produce appropriate management information M4 Assess the effectiveness of the testing, including an explanation of the choice of test data used M5 Produce technical and user documentation for a fully functional system, including ER Diagram and normalization statements and describing how the system works D3 Assess any future improvements that may be required to ensure the continued effectiveness of the database system 5|Page Content Introduce 16 I - Develop the database system 1.1 Final Mock-up of the application .9 1.2 Queries to create database with results 12 A - Table design of Login .12 B - Table design of Staff .13 C - Table design of Customer 13 D - Table design of Bill 14 E - Table design of Bill’s detail 14 F - Table design of Product 15 G - Table design of Rate 15 II – Produce queries .16 2.1 Queries to INSERT data with illustrations of final result 16 A - Insert into table Login .16 B - Insert into table Staff .17 C - Insert into table Customer .18 D - Insert into table Bill 19 E - Insert into table Bill’s detail 20 F - Insert into table Product 22 G - Insert into table Rate .23 2.2 Queries to UPDATE data with illustrations of final result 24 2.3 Queries to DELETE data with illustrations of final result .26 2.4 Queries to SELECT data with illustrations of final result 28 2.5 Advanced queries: Stored procedures, triggers, functions .34 A - Stored procedures 34 B - Triggers in SQL 35 C - Function 36 2.6 Evaluate the effectiveness of the database solution 38 III – Test the system 38 3.1 Test cases 38 6|Page Content of figure Figure : The login screen .9 Figure : Primary interface Figure : Profile’s staff 10 Figure : Details of the customer 10 Figure : Details of Bill .11 Figure : Information of Bill's details 11 Figure : Product descriptions 12 Figure : Information of Rate 12 Figure : Login panel design .13 Figure 10 : Staff panel design 13 Figure 11 : Customer panel design .14 Figure 12 : Bill panel design 14 Figure 13 : Bill’s detail panel design 15 Figure 14 : Product panel design 15 Figure 15 : Rate panel design .16 Figure 16 : Source code to insert to the table Login 17 Figure 17 : Add successful data to the table Login 17 Figure 18 : Source code to insert to the table Staff 18 Figure 19 : Add successful data to the table Staff 18 Figure 20 : Source code to insert to the table Customer 19 Figure 21 : Add successful data to the table Customer 19 Figure 22 : Source code to insert to the table Bill 20 Figure 23 : Add successful data to the table Bill 20 Figure 24 : Source code to insert the table BillDetail 21 Figure 25 : Add successful data to the table BillDetail 21 Figure 26 : Source code to insert the information to the table Product 22 Figure 27 : Add successful data to the table Product 22 Figure 28 : Source code to insert the information on the table Rate .23 Figure 29 : Add successful information on the table Rate 24 Figure 30 : Product table after the number of products has been updated 25 7|Page Figure 31 : Customer table after the number of products has been updated 26 Figure 32 : Bill table after the number of products has been updated 26 Figure 33 : Login table after the number of products has been deleted 27 Figure 34 : Product table after the number of products has been deleted 28 Figure 35 : Select products with a price of less than 10,000,000 29 Figure 36 : Select 50 percent of Staff 30 Figure 37 : Select Staff's ID with the number 05, 06, 07 from the Login table 31 Figure 38 : Select the product's ID and name of the product costing from 15,000,000 to 30,000,00 .32 Figure 39 : Count the total bill 32 Figure 40 : The average price of the product costs from 1,000,000 to 10,000,000 33 Figure 41 : Select top and top Price of Product 33 Figure 42 : Calculate the total product value and are about to increase in order 34 Figure 43 : The syntax for generating Stored procedure 35 Figure 44 : The syntax for generating Trigger 36 Figure 45 : The syntax for generating Function 37 Figure 46 : Discount function of the product 38 8|Page I - Develop the database system 1.1 Final Mock-up of the application A comprehensive blueprint of the system was created based on the existing mock-up designs from the prior job This update adds additional statistics querying capabilities for library administration Figure 1: The login screen Figure 2: Primary interface 9|Page Figure 34: Product table after the number of products has been deleted 2.4 Queries to SELECT data with illustrations of final result I attempted to select the data in various database tables to see if the update function worked Users can update data with the syntax “SELECT column list FROM table name WHERE condition” The following are the results of my testing using some database tables 28 | P a g e Figure 35: Select products with a price of less than 10,000,000 29 | P a g e Figure 36: Select 50 percent of Staff 30 | P a g e Figure 37: Select Staff's ID with the number 05, 06, 07 from the Login table 31 | P a g e Figure 38: Select the product's ID and name of the product costing from 15,000,000 to 30,000,00 Figure 39: Count the total bill 32 | P a g e Figure 40: The average price of the product costs from 1,000,000 to 10,000,000 Figure 41: Select top and top Price of Product 33 | P a g e Figure 42: Calculate the total product value and are about to increase in order 2.5 Advanced queries: Stored procedures, triggers, functions Companies process massive amounts of data in order to extract insights for future company development Leaders aspire and strive to make their firms market leaders in their respective fields, thus they want database engineers to extract more usable data As a result, I discovered the following methods for them to effortlessly retrieve information A - Stored procedures SQL Server could indeed function without stored procedures They may provide a great deal of assistance with programming and database administration After using a Stored Procedure in the database once, we must call it many more times in the database The performance of the Stored Procedure statement is improved, and the bandwidth is reduced Furthermore, SQL Server includes high-level activities that ordinary users cannot access By often making available to users the Stored Procedure that has access to these tasks As a result, users frequently get access indirectly without jeopardizing SQL Server's security 34 | P a g e Figure 43: The syntax for generating Stored procedure B - Triggers in SQL A trigger is a collection of SQL statements with unique names that live in system memory It is a type of stored procedure that is invoked automatically when a database server event occurs Each trigger is always linked to a table A trigger is referred to as a special procedure because, unlike a stored procedure, it cannot be invoked directly The main difference between a trigger and a procedure is that a trigger is automatically called when a data change event happens against a table In contrast, a stored process must be called explicitly 35 | P a g e Figure 44: The syntax for generating Trigger C - Function A function is a collection of SQL statements that accomplishes a specific task Functions promote code reuse If you have to write large SQL scripts to perform the same task repeatedly, you can create a function that does it Instead of trying to rewrite the SQL, users can start calling that function the next time A function accepts parameters as input and outputs a value SQL Server contains a set of built-in functions for a variety of tasks Of course, you could establish a stored procedure to group and execute a set of SQL statements; however, stored procedures can't be called from within SQL statements In contrast, functions can be Another problem with functions is that they require to be called for each row As a result, if you use functions with large amounts of data, you may experience performance issues 36 | P a g e Figure 45: The syntax for generating Function 37 | P a g e Figure 46: Discount function of the product 2.6 Evaluate the effectiveness of the database solution In accordance with the prerequisites of the online database, significant tables have already been built for sign up to, distinguish among both customers and staff to build basic information of members such as name, ID, email, contact information, and address; Bill includes Bill's ID information, staff ID, customer ID, and date of payment; Bill's detail information including such Bill's ID, product ID, and quantity; In response to management's request, the login table is utilized to regulate logins and improve database security DataValidation is also configured such that if the information submitted is incorrect, the secondary table information will be changed or destroyed if the primary table information is edited or removed These tables essentially make the database easier to use Users can also add, modify, remove, and view data Next, statistical operations make use of Select, a mechanism that allows administrators to easily regulate library activities When changing or removing data, triggers help save client information A user-friendly prototype has already been created, as well as a complete how-to guide to help the user fully comprehend the system's capabilities and operation In summary, the system satisfied the majority of the user's requirements III – Test the system 3.1 Test cases Test What is How Test data used Expected Actual results 38 | P a g e being test results Insert Enter data into information of the system Login table Insert into Login(StaffID, Password, No) Data was successfully entered Successful Update Enter data into information of the system Login table update Login Set No = ‘05’ where No = 5; Data was successfully entered Successful Delete Execute the information of statement to Login table delete the data of the table delete from Login where Password = 'Ki135'; Data was successfully entered Successful Display Use command information of to display data Login table Select StaffID, Password from Login; Data was successfully entered Successful Insert Enter data into information of the system Staff table insert into Staff(StaffID, StaffName, StaffPhone, StaffEmail, StaffAddress, StaffFunction) Data was successfully entered Successful Values (‘FS486’, ‘Ha486’, ‘11’); values ('FS265', 'Le Ngoc Anh Tu', '0952795623', 'tufs265@fpr.vn', '23/8 Nguyen Trai', 'Sales supervisor'); Update Enter data into information of the system Staff table update Staff Set StaffName = ‘Le Ngoc Anh Hy’ where StaffName = ‘Le Ngoc Anh Thy’; Data was successfully entered Successful Delete Execute the information of statement to Staff table delete the data of the table delete from Staff where StaffPhone = '099956797'; Data was successfully entered Successful Display Use command information of to display data Staff table select StaffID, StaffName from Staff; Data was successfully entered Successful Insert Enter data into information of the system Customer table insert into Customer(CustomerID, CustomerName, CustomerPhone, CustomerAddress) Data was successfully entered Successful values ('Arc563', 'Nguyen Thi 39 | P a g e Kieu Lan', '0832608989', '125/5 Ki Con'); 10 Update Enter data into information of the system Customer table update Customer Set Data was CustomerAddress = ‘665 successfully Thanh Thai’ where entered CustomerAddress = ‘65 Thanh Thai’; Successful 11 Delete information of Customer table delete from Customer where CustomerAddress = '82 Binh Gia'; Data was successfully entered Successful 12 Display Use command information of to display data Customer table Select CustomerID, CustomerName from Customer; Data was successfully entered Successful 13 Insert Enter data into information of the system Bill table insert into Bill(BillID, StaffID, Data was CustomerID, Date) successfully entered values ('B11', 'FS246', 'Bcd456', '2022-07-19'); Successful 14 Update Enter data into information of the system Bill table update Bill Set BillID = ‘B01’ where BillID = ‘B1’; Data was successfully entered Successful 15 Delete Execute the information of statement to Bill table delete the data of the table delete from Bill where Date = '2022-06-18'; Data was successfully entered Successful 16 Display Use command information of to display data Bill table select BillID, Date from Bill; Data was successfully entered Successful 17 Insert Enter data into information of the system BillDetail table insert into BillDetail(BillID, ProductID, Quantity) Data was successfully entered Successful 18 Update Enter data into information of the system BillDetail table update BillDetail Set Quantity = where Quantity = 3; Data was successfully entered Successful 19 Delete information of BillDetail table delete from BillDetail where Quantity = 5; Data was successfully entered Successful Execute the statement to delete the data of the table Execute the statement to delete the data of the table values ('B11', 'LT54', '2'); 40 | P a g e 20 Display Use command information of to display data BillDetail table Select BillID, ProductID from BillDetail; Data was successfully entered Successful 21 Insert Enter data into information of the system Product table insert into Product(ProductID, Data was ProductName, Price, Quantity) successfully entered values ('LT16', 'Laptop HP Successful Gaming Victus 16-e0175AX R5 5600H/8GB/512GB/16.1 ', '20490000', '56'); 22 Update Enter data into information of the system Product table update Product Set Quantity = 50 where Quantity = 84; Data was successfully entered Successful 23 Delete Execute the information of statement to Product table delete the data of the table delete from Product where Price = '3799000'; Data was successfully entered Successful 24 Display Use command information of to display data Product table select ProductName, Price from Product where Price > 1000; Data was successfully entered Successful 25 Insert Enter data into information of the system Rate table insert into Rate (CustomerID, ProductID, Evaluation) Data was successfully entered Successful 26 Update Enter data into information of the system Rate table update Rate Set Evaluation = ‘Good’ where Evaluation = ‘Excellent’; Data was successfully entered Successful 27 Delete Execute the information of statement to Rate table delete the data of the table delete from Rate where Evaluation = 'Average'; Data was successfully entered Successful 28 Display Use command information of to display data Rate table select Evaluation from Rate; Data was successfully entered Successful values ('Bcd456', 'LT54', 'Good'); 41 | P a g e References Xuanthulab.net 2022 Mệnh đề UPDATE cập nhật liệu SQL [online] Available at: [Accessed 18 October 2022] Xuanthulab.net 2022 Mệnh đề DELETE xóa liệu SQL [online] Available at: [Accessed 18 October 2022] Xuanthulab.net 2022 SELECT quy tắc SQL [online] Available at: [Accessed 18 October 2022] 2022 [online] Available [Accessed 18 October 2022] at: Viblo 2022 Giới thiệu Stored Procedure SQL Server [online] Available [Accessed October 2022] at: 18 www.javatpoint.com 2022 Triggers in SQL Server - javatpoint [online] Available at: < https://www.javatpoint.com/triggers-in-sqlserver#:~:text=A%20trigger%20is%20a%20set,always%20associated%20with%20a%20table.> [Accessed 18 October 2022] Richardson, B and →, V., 2022 How to use SQL Server built-in functions and create user-defined scalar functions [online] SQL Shack - articles about database auditing, server performance, data recovery, and more Available at: [Accessed 18 October 2022] SQL scalar functions (2020) Db2 11 - Application programming and SQL - SQL scalar functions Available at: https://www.ibm.com/docs/en/db2-for-zos/11?topic=function-sql-scalar-functions (Accessed: October 21, 2022) 42 | P a g e

Ngày đăng: 10/02/2023, 17:28

Xem thêm:

w