Docsity

database assignment (2021/2022), Assignments of Database Programming

Toggle sidebar
bg1
1
PROGRAM TITLE: ……Assignment BKC………………………………………
UNIT TITLE: …………Unit 4: Database Design and
Development……………………………………….
ASSIGNMENT NUMBER: ……4……………………………
ASSIGNMENT NAME: ……Database design and development ……………………………….
SUBMISSION DATE: ………17/03/2022……………………………….
DATE RECEIVED: ……………01/03/2022……………………………….
TUTORIAL LECTURER: ……Nguyễn Ngọc Tân………………………………
WORD COUNT: ………5664 words……………………………………..
STUDENT NAME: Trần Minh Đạt
………………………………………………
STUDENT ID: ………BKC12302
…………………………………………….
MOBILE NUMBER: 0903512002
……………………………………………
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44

Partial preview of the text

Download database assignment (2021/2022) and more Assignments Database Programming in PDF only on Docsity!

PROGRAM TITLE: ……Assignment BKC……………………………………… UNIT TITLE: …………Unit 4: Database Design and Development………………………………………. ASSIGNMENT NUMBER: …… 4 …………………………… ASSIGNMENT NAME: ……Database design and development ………………………………. SUBMISSION DATE: ………17/03/2022………………………………. DATE RECEIVED: ……………01/03/2022………………………………. TUTORIAL LECTURER: ……Nguyễn Ngọc Tân……………………………… WORD COUNT: ……… 5664 words…………………………………….. STUDENT NAME: Trần Minh Đạt ……………………………………………… STUDENT ID: ………BKC ……………………………………………. MOBILE NUMBER: 0903512002 ……………………………………………

Summative Feedback: Internal verification:

TABLE OF CONTENTS

A. INTRODUCTION: .............................................................................................. 10

  1. What is an database?:..................................................................................... 10 B. CONTENT: ....................................................................................................... 10 [LO1] Use an appropriate design tool to design a relational database system for a substantial problem: ............................................................................................... 10 (P1). Design a relational database system using appropriate design tools and techniques, containing at least four interrelated tables, with clear statements of user and system requirements: .................................................................................... 10
  2. User and system requirements: ..................................................................... 10
  3. Identify entities and attributes: ....................................................................... 11 a. Analysis: ...................................................................................................... 11 b. Identify entities and attributes:..................................................................... 11
  4. Designing ER diagram: .................................................................................. 13 a. ER diagram symbols relationship and notations: ........................................ 13 b. Designing ER diagram: ............................................................................... 15
  5. Logical database design (Relational schema): .............................................. 16 (M1). Produce a comprehensive design for a fully functional system which includes interface and output designs, data validations and data normalisation:................ 17
  6. Data normalization: ........................................................................................ 17 a. First normal form: ........................................................................................ 18 b. Second normal form: ................................................................................... 18 c. Third normal form: ....................................................................................... 19 d. Fourth normal form (Boyce Codd normal form): .......................................... 20
  7. Data validations: ........................................................................................... 20 (D1). Evaluate the effectiveness of the design in relation to user and system requirements: ...................................................................................................... 22 [LO2]. Develop a fully functional relational database system, based on an existing system design: ..................................................................................................... 23 (P2). Develop the database system with evidence of user interface, output, and data validations, and querying across multiple tables: ................................................ 23 a. Develop a relational database system based on the ER diagram above:..... 23 b. Provide evidence of the use of a suitable IDE to create a simple interface to insert, update and delete data in the database: ........................................ 36 c. Implement the validation methods: ............................................................... 38

(P3). Implement a query language into the relational database system: ............. 38 (M2). Implement a fully functional database system which includes system security and database maintenance: ................................................................... 40 (M3) Assess whether meaningful data has been extracted through the use of query tools to produce appropriate management information: ............................ 41 [LO3]. Test the system against user and system requirements: ........................... 44 (P4) Test the system against user and system requirements:............................. 44 (M4) Assess the effectiveness of the testing, including an explanation of the choice of test data used: ............................................................................... 47 (D2) Evaluate the effectiveness of the database solution in relation to user and system requirements, and suggest improvements: ...................................... 47 [LO4] Produce technical and user documentation: ............................................... 48 (P5) Produce technical and user documentation:................................................ 48

  1. SQL Server Installation: ................................................................................. 48
  2. Install Microsoft SQL Server Management Studio: ........................................ 58
  3. Technical documentation: .............................................................................. 61 (M5) Produce 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: ................................. 62 (D3) Evaluate the database in terms of improvements needed to ensure the continued effectiveness of the system:.......................................................... 67 C. REFERENCES: .................................................................................................. 68
  • Figure 1. Fields
  • Figure 2. Foreign keys
  • Figure 3. Types.............................................................................................
  • Figure 4. Cardinality and Ordinality
  • Figure 5. ER diagram
  • Figure 6. Relational schema
  • Figure 7. First normal form
  • Figure 8. Second normal form
  • Figure 9. Third normal form
  • Figure 10. Not null
  • Figure 11. Unique
  • Figure 12. Check.................................................................................................
  • Figure 13. Primary key
  • Figure 14. Foreign key..................................................................................
  • Figure 15. Create database
  • Figure 16. Use database
  • Figure 17. product lines table
  • Figure 18. vendor table
  • Figure 19. product table
  • Figure 20. sales table
  • Figure 21. staff table
  • Figure 22. customer table
  • Figure 23. order table
  • Figure 24. order items table
  • Figure 25. Insert product lines values
  • Figure 26. Select all from product lines
  • Figure 27. Insert vendor values
  • Figure 28. Select all from vendor
  • Figure 29. Insert product values
  • Figure 30. Select all from product
  • Figure 31. Insert sales values
  • Figure 32. Select all from sales
  • Figure 33. Insert staff values
  • Figure 34. Select all from staff
  • Figure 35. insert customer values.................................................................
  • Figure 36. Select all from customer
  • Figure 37. Insert order values
  • Figure 38. Select all from order
  • Figure 39. Insert order items values
  • Figure 40. Select all from order items
  • Figure 41. Login SQL Server
  • Figure 42. SQL Server home screen
  • Figure 43. SELECT
  • Figure 44. UPDATE
  • Figure 45. DELETE
  • Figure 46. BETWEEN...................................................................................
  • Figure 47. Group by......................................................................................
  • Figure 48. Order by
  • Figure 49. WHERE
  • Figure 50. Test
  • Figure 51. Test
  • Figure 52. Test
  • Figure 53. Test
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure
  • Figure 73. Login process
  • Figure 74. Insert data process
  • Figure 75. Update data process
  • Figure 76. Delete data process.....................................................................
  • Figure 77. Search data process....................................................................
  • Figure 78. Logout process

A. INTRODUCTION

  • Nowadays, a database system is a very important system in every business. A database system is used to store, retrieve, and run queries on data. A database system also can manage the data, the database engine, and the database schema, allowing for data to be manipulated or extracted by users and other programs
  • Here I propose to develop a new database system for BKC, a local double- glazing company since their old database system is now too slow.
  • The main objective of this project is to develop a new database system and also investigate the system requirements, design, create and implement the system to help develop the new database system. 1. What is an database?
  • A database is an organized collection of data, generally stored and accessed electronically from a computer system. Where databases are more complex they are often developed using formal design and modelling techniques.
  • There are different types of databases, and there are 3 main types:  Flat file database: is a type of database that stores data in a single table, flat file databases are generally in plain-text form, where each line holds only one record. The fields in the record are separated using delimiters such as tabs and commas.  Relational database (RDB): is a collective set of multiple data sets organized by tables, records and columns. RDBs establish a well-defined relationship between database tables. Tables communicate and share information, which facilitates data searchability, organization and reporting.  Non-relational database: The non-relational form of database organization is more forgiving in its structure and form than relational databases. Instead of tables with columns and rows, they have collections of different categories

B. CONTENT

[LO1] Use an appropriate design tool to design a relational database system for a substantial problem. (P1). Design a relational database system using appropriate design tools and techniques, containing at least four interrelated tables, with clear statements of user and system requirements.

1. User and system requirements - User requirements:

 Updated information  Record all the details about the information  The data should be secured

  • System requirements:  The company needs computers to run database system  The employees who have knowledge about database and maintain database  SQL server 2019: will need hard disk space of 6GB 2. Identify entities and attributes a. Analysis
  • BKC, a local double-glazing company, supplies a huge range of windows and door  product, product lines
  • They buy most of their products in bulk from a few large manufacturers and store the products in their warehouse  vendor
  • They currently have sales agents who follow up sales leads which are mainly generated from their marketing material  sales
  • Calls taken by staff in the company office  staff
  • Each visit from lead results in a quote  customer
  • Some of these quote’s result in an actual sale, either to supply only or to supply and install  order, order items b. Identify entities and attributes Entities Fields product product_id, product_name, product_quantity, product_price, product_unit Product lines Proline_id, proline_name vendor Vendor_id, CompanyName, vendor_phone sales Sales_id, sales_quantity, sales_date, sales_total staff Staff_id, staff_date, staff_phone, staff_birth customer Cus_id, cus_name, cus_phone, address orders Order_id, order_date, order_total order items INT IDENTITY, amount, unit_price
  • Product:  Product_id: product number

 Unit_price: unit price

3. Designing ER diagram a. ER diagram symbols relationships and notations Attribute symbol Name Description Attribute Attributes are characteristics of an entity, a many-to-many relationship, or a one- to-one relationship. Multivalued attribute Multivalued attributes are those that are can take on more than one value Derived attribute Derived attributes are attributes whose value can be calculated from related attribute values. Relationship Relationships are associations between or among entities

  • Fields: Fields represent the portion of a table that establish the attributes of the entity. Attributes are typically thought of as columns in the database that the ERD models

Figure 1. Fields

  • Keys: Keys are one way to categorize attributes. ER diagrams help users to model their databases by using various tables that ensure that the database is organized, efficient, and fast. Keys are used to link various tables in a database to each other in the most efficient way possible.
  • Primary keys: Primary keys are an attribute or combination of attributes that uniquely identifies one and only one instance of an entity.
  • Foreign keys: Foreign keys are created any time an attribute relates to another entity in a one-to-one or one-to-many relationship Figure 2. Foreign keys
  • Types: Types refer to the type of data in the corresponding field in a table. Types can also refer to entity types, which describe the composition of an entity Figure 3. Types

Figure 5. ER diagram

4. Logical database design (Relational schema)

Figure 6. Relational schema (M1). Produce a comprehensive design for a fully functional system which includes interface and output designs, data validations and data normalization.

1. Data normalization - Normalization is the process of organizing data in a database. This includes creating tables and establishing relationships between those tables according to rules designed both to protect the data and to make the database more flexible by eliminating redundancy and inconsistent dependency. - Normalization is used for:  Eliminate redundant data and inconsistent dependency  Ensure data dependencies make sense - There are 5 types of data normalization forms:  First normal form

 Note the multiple Class# values for each Student# value in the above table. Class# is not functionally dependent on Student# (primary key), so this relationship is not in second normal form.  The following tables demonstrate second normal form: Students: Registration: Figure 8. Second normal form c. Third normal form

  • Third normal form is the third step of normalization
  • Third normal form is use to eliminate fields that do not depend on the key.
  • Values in a record that are not part of that record's key do not belong in the table. In general, anytime the contents of a group of fields may apply to more than a single record in the table, consider placing those fields in a separate table.
  • A table is in third normal form if: A table is in 2nd normal form. It contains only columns that are nontransitive dependent on the primary key
  • Example:  In the second normal form example above, Adv-Room (the advisor's office number) is functionally dependent on the Advisor attribute. The solution is to

move that attribute from the Students table to the Faculty table, as shown below: Students: Faculty: Figure 9. Third normal form d. Fourth normal form (Boyce Codd normal form)

  • Fourth normal form is the latest version of normalization. This form handles certain anomalies that cannot be handled by 3rd normal form.
  • For a table to be in BCNF, following conditions must be satisfied:  R must be in 3rd Normal Form  for each functional dependency (X → Y), X should be a super Key. 2. Data validations
  • Data validation is a process that ensures the delivery of a clear data to the program. It checks for the integrity and validity of data that is being input to different software and its components. Data validation is also known as input validation
  • There are many types of data validations:  Check digit: A redundancy check used for error detection. It is used to check if the range of numbers are entered correctly  Type Check: this is a way to confirm that the correct data type is inputted  Length check: Allows checking if the data entered is not short or long. this is used to make sure that the correct number of characters are entered into the field