Docsity

Assignment 1 database 2022, Thesis of Database Programming

Partial preview of the text

Download Assignment 1 database 2022 and more Thesis Database Programming in PDF only on Docsity!

PROGRAM TITLE: BTEC COMPUTING

UNIT TITLE: Database Design and Development ASSIGNMENT NUMBER: 1 ASSIGNMENT NAME: Phone Management System SUBMISSION DATE: 22/09/ DATE RECEIVED: 29/10/ TUTORIAL LECTURER: Pham Son Tung WORD COUNT: 5450 STUDENT NAME: Chu Thanh Thuong STUDENT ID: BKC MOBILE NUMBER: 0399310282

Summative Feedback: You need to repeat your assignment since it did not match the requirements. You have met the following criteria: P2, P3, P4, M1, M2, M Strength:  You know how to design a relational database system using the right design tools and techniques, analyze entities as required by the task, build ER diagrams.  You know how to create tables and implement query languages into relational database systems.  You already know the test documentation to test the system according to user and system requirements including the data flow diagram.  You know how to create a decentralized account to ensure the safety of the system.  You have Data Validation.  Already know how to normalize the database. Weakness:  RDS is not correct (the direction of the arrow reference is not correct, it is reversed).  Instructions for installing and using SQL server while choosing to use MySQL. How to improve:  The RDS should be re-presented.  Need guidance on installation and correct use of the selected RDBMS to use. Grade: Fail Date: 05/11/ Assessor: Pham Son Tung

  • I. Introduction.............................................................................................................................................. Contents
  • II. Theory......................................................................................................................................................
    1. Database..................................................................................................................................................
    1. Relational database.................................................................................................................................
    1. Entity-relationship diagrams....................................................................................................................
    1. Relational schema..................................................................................................................................
    1. DBMS.....................................................................................................................................................
    1. Database normalization.........................................................................................................................
    1. Query language......................................................................................................................................
    1. System testing.......................................................................................................................................
  • III. Practive.................................................................................................................................................
    1. Analyze real problems, the database information needs to be stored..................................................
    1. List of Entities........................................................................................................................................
    1. Entity Attributes.....................................................................................................................................
    1. Relationships of entities........................................................................................................................
    1. ERD........................................................................................................................................................
    1. Relational schema..................................................................................................................................
    1. Constraints in the database...................................................................................................................
    1. Detailed settings....................................................................................................................................
    1. Database diagram..................................................................................................................................
    1. Query statements used in the created database.................................................................................
    1. Normalize created database................................................................................................................
    1. System security, database maintenance.............................................................................................
  • IV. Apply the test to the created database................................................................................................
    1. Test log..................................................................................................................................................
    1. Test case................................................................................................................................................
  • V. Technical and user documentation.......................................................................................................
    1. Used RDBMS Tutorial and Installation...................................................................................................
    1. RDBMS User Manual..............................................................................................................................
    1. Describe how the database system works including data flow diagrams and flowcharts.....................
  • VI. Conclusion............................................................................................................................................
    1. Evaluate design performance in relation to user and system requirements.........................................
    1. Evaluate the effectiveness of the database solution in relation to user and system requirements.......
  • system....................................................................................................................................................... 3. Evaluate the database for necessary improvements to ensure the continued effectiveness of the
  • VII. References...........................................................................................................................................

I. Introduction Many technology aficionados choose to trade in mobile phones or devices. Because there are many participants and all information is open and accessible, this is an attractive but also tremendously competitive area. Customers may quickly compare items from different retailers. Phone store management features: High-value items must be recognized; the most popular method is to manage by IMEI. The administration of phones by IMEI is also directly tied to the manufacturer's warranty. Customer and supplier information is critical for business owners to manage debt, the cost of items sold, and customer care services. Because the value of products is considerable, calculating the cost of items requires precision. Difficulties in managing workers and finances.Lack of precise and thorough control over day- end collections and payments. And the software we developed assists you: Handle IMEI, allowing you to easily manage the import and export of items. Excellent warranty and customer service help. Allows for simple administration of commodities based on model, capacity, and color. Store accurate and detailed information on customers and suppliers.

  • Relationship

3. Entity-relationship diagrams - Entity-relationship diagrams, abbreviated as ERDs, represent the relationships of a set of entities stored in a database. Diagrams assist in explaining the logical structure of the database. ERD includes many specialized symbols, and its meaning makes this pattern unique. - Porpose: + Helps define terms related to entity-relationship modeling. + Give a demo to preview how all the tables in the DBMS will be connected, what fields or attributes will be on each table. + Describe entities, attributes, and relationships. + Entity-relationship diagrams can be converted to relational tables, thus allowing for rapid database construction. + Entity-relationship diagrams are used by database designers as a blueprint for implementing data in applications and software. + ERD allows to convey the logical structure of the database to the user. - The components: + An entity is a thing in the real world, whether it exists or not, that may or may not be recognizable. + An attribute is a characteristic that holds a value for an entity type or a relation type. + A relationship is an association between two or more entities. Entities that participate in one or more relationships. Relationships are often defined to include things or events with verbs that affect each other.  1 – 1  1 – n  N – n  0 – 1  0 – n + Symbols in entity-relationship diagrams

  • Dbdiagram.io  Draw.io was chosen to apply the ERD drawing of the needed software in the task.

4. Relational schema - Relational schema A relational schema is a set of relational tables and associated items that are related to one another. - Purpose: it shows what connections make up the database. - How to convert an ERD schema to a relational schema + Step 1: Determine the relationship of entities to each other  Convert 1 - 1 connections that consolidate two entities into one.  1 - n relationships use the entity n's primary key as the foreign key of entity 1.  The n - n relationship forms an entity that mediates the relationship to 1 – n + Step 2: Check the normal form of the relations. 5. DBMS - A database management system (DBMS) is a software package used to define, manipulate, retrieve, and manage data. The management system will usually manipulate the data of the DBMS itself. For example: data format, file name, record structure, and file structure. - Role: A database management system is an automated system that enables users to control information, create, update and maintain databases. In which, two main components in a DBMS are: Query processor (request processor) and data manager. - Some database management systems. + MySQL + SQL Server + SQLite + Redis + MongoDB + PostgreSQL + Oracle

 SQL Server is my choice for software application

6. Database normalization - Database normalization is a scientific method to decompose a complex structured table into simple structured tables according to rules that ensure no data loss. - Types of data normalization: + 1NF (First Normal Form): Definition: A table (relation) is said to be in 1NF normal form if and only if all of its domains contain only atomic (prime) values. Example: + 2NF: Defines a relation in 2NF normal form if the relation:  Is 1NF  Non-key attributes must be fully functionally dependent on the primary key Example:

  • SELECT Used to query records that meet specified conditions. Syntax: SELECT * FROM table_name; or SELECT column1, column2, ... FROM table_name;
  • INSERT Used to insert a series of data into the database with a manipulation. Syntax: INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);
  • UPDATE Used to change the values of records or attributes some. Syntax: UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
  • DELETE Used to delete records from a table. Syntax: DELETE FROM table_name WHERE condition;
  • FROM Used to specify the table name where records are selected. WHERE Used to specify the condition that records must meet in order to be selected. GROUP BY Used to divide records into separate groups. ORDER BY Used to sort the selected records in a specified order. Syntax: SELECT [DISTINCT|ALL]{*| | [AS ]} FROM [] [, …] [WHERE ] [GROUP BY ] [HAVING ] [ORDER BY ]

    8. System testing - System testing is a method of monitoring and evaluating the behavior of a complete and fully integrated software product or system, against a predefined specification and functional requirements. - Purpose: + Software testing is an extremely important step in the process of developing a technology product. It shows errors and mistakes that have been made in the development stages. + System testing ensures the reliability of the customers and their satisfaction on the application they create + Helps increase work efficiency by minimizing the time it takes to find bugs on a software application or product many times + Software testing is necessary because it helps to deliver software applications to customers that deliver high quality products or lower software application maintenance costs, more economically and thus lead to better performance. highest and more reliable results. + Done in an environment similar to production, allowing developers as well as stakeholders to get an idea of the user's reaction to the product. + This process specifically ensures that the application does not lead to any errors, minimizing costs in the future or during the product development stages.

    4. Relationships of entities 1 manufacturer has many product, 1 product has 1 manufacturer  The relationship between manufacturer and product: 1 – n 1 product has many bill_detail, 1 bill_detail has 1 product  The relationship between product and bill_detail: 1 – n 1 bill has many bill_detail, 1 bill_detail has 1 bill  The relationship between bill and bill_detail: 1 – n 1 employed has 1 account, 1 account has 1 employed  The relationship between employed and account: 1 – 1 1 customer has account, 1 account has 1 customer  The relationship between account and customer: 1 – 1 1 payment has many bill, 1 bill has 1 payment  The relationship between payment and bill: 1 – n 1 shipping has many bill, 1 bill has 1 shipping  The relationship between shipping and bill: 1 – n 5. ERD

    **6. Relational schema

    1. Constraints in the database**
      • Product field Type size constraints IMEI INT PK NAME NVARCHAR 100 NOT NULL RELEASE_DATE DATE

    ID_ACCOUNT INT PK

    NAME_ACCOUNT NVARCHAR 100 NOT NULL

    PASSWORD NVARCHAR 100 NOT NULL

    ROLE NVARCHAR 100 NOT NULL

    • Payment_method field type size constraints ID_PAYMENT_METHOD INT PK NAME_PAYMENT_METHOD NVARCHAR 100 NOT NULL
    • Shipping_method field type size constraints ID_SHIPPING_METHOD INT PK NAME_SHIPPING_METHOD NVARCHAR 100 NOT NULL
    • Bill Field type size constraints ID_BILL INT PK PURCHASE_DATE DATE ID_CUSTOMER INT FK ID_EMPLOYED INT FK ID_SHIPPING_METHOD INT FK ID_PAYMENT_METHOD INT FK
    • Bill_detail field Type size constraints ID_BILL INT FK

    IMEI INT FK

    AMOUNT INT

    PRICE FLOAT 3

    8. Detailed settings CREATE DATABASE assignment USE assignment CREATE TABLE product( IMEI INT PRIMARY KEY , NAME NVARCHAR( 100 ) NOT NULL, RELEASE_DATE DATE , PHONE_SIZE FLOAT( 3 ), PRICE FLOAT( 3 ), ID_MANUFACTURER INT FOREIGN KEY REFERENCES manufacturer(ID_MANUFACTURER) ) CREATE TABLE manufacturer( ID_MANUFACTURER INT PRIMARY KEY , NAME_MANUFACTURER NVARCHAR( 100 ) NOT NULL ) CREATE TABLE customer( ID_CUSTOMER INT PRIMARY KEY, NAME_CUSTOMER NVARCHAR( 100 ) NOT NULL, ADDRESS NVARCHAR( 100 ) NOT NULL, PHONE_NUMBER VARCHAR( 10 ) NOT NULL, ID_ACCOUNT INT FOREIGN KEY REFERENCES account(ID_ACCOUNT) ) CREATE TABLE employed( ID_EMPLOYED INT PRIMARY KEY, NAME_EMPLOYED NVARCHAR( 100 ) NOT NULL, EMAIL NVARCHAR( 40 ) NOT NULL, PHONE_NUMBER VARCHAR( 10 ) NOT NULL, ID_ACCOUNT INT FOREIGN KEY REFERENCES account(ID_ACCOUNT) ) CREATE TABLE account( ID_ACCOUNT INT PRIMARY KEY, NAME_ACCOUNT NVARCHAR( 100 ) NOT NULL, PASSWORD NVARCHAR( 100 ) NOT NULL, ROLE NVARCHAR( 100 ) NOT NULL ) CREATE TABLE payment_method(