You are on page 1of 40

PROGRAM TITLE: BTEC in Computing (Software Engineering)

UNIT TITLE: Database Design & Development

ASSIGNMENT NUMBER: Assignment 1

ASSIGNMENT NAME: Assignment 1

SUBMISSION DATE: 25/6/2022

DATE RECEIVED: 25/6/2022

TUTORIAL LECTURER: Nguyen Duc Giang

WORD COUNT: 2750

STUDENT NAME: Trinh Van Duc

STUDENT ID: BKC12318

MOBILE NUMBER: (+84) 943306660


Summative Feedback:

Internal verification:
Contents
A. INTRODUCTION.............................................................................................................................................. 4
B. SYSTEM REQUIREMENTS ........................................................................................................................... 4
I. Real world scenario........................................................................................................................................ 4
II. Data requirement for storage .......................................................................................................................... 4
III. Relationship between entities............................................................................................................................. 6
C. DATABASE DESIGN ....................................................................................................................................... 6
I. ER Diagram .................................................................................................................................................... 6
1. What is ER diagram? ................................................................................................................................ 6
2. Role of ER Diagram in database design process: .................................................................................... 7
3. Basic components of ER Diagram ............................................................................................................ 7
4. Build ER Diagram...................................................................................................................................... 9
5. Software that supports drawing ER Diagram ....................................................................................... 10
II. Convert from associative entity diagram to relational schema............................................................ 11
1. Relational schema .................................................................................................................................... 11
2. Convert from ER Diagram to Relational Diagram. .............................................................................. 12
III. Normalization ........................................................................................................................................... 16
1. The goal of standardization ..................................................................................................................... 17
2. Nomalization divided into what type ...................................................................................................... 17
IV. Relational database system ..................................................................................................................... 17
1. Design Database. ...................................................................................................................................... 17
D. Test ................................................................................................................................................................ 22
E. SYSTEM SECURITY AND MAINTAINACE ......................................................................................... 22
F. TECHNICAL AND USER DOCUMENT .............................................................................................................. 22
1. MySQL Workbench for design Database .................................................................................................. 22
Object Management ............................................................................................................................................... 23
Connection Management ....................................................................................................................................... 24
2. Install MySQL and MySQL Workbench. .................................................................................................... 24
G. REFERENCES ................................................................................................................................................... 40
A. INTRODUCTION
Currently, there are many stores that do not use technology to manage the store's operating system
or have outdated technology that cannot meet the growing needs and Glass Shop is one of them.
manage its operations using a computer system developed by a university. student 5 years ago. The
current system is too slow and no system documentation is created at deployment time to prevent
this. You can easily make changes to the system. Therefore, GS invited the database development
team of a large IT consulting company to advise on document development and database design for
the project. A new system that meets current customer needs.

B. SYSTEM REQUIREMENTS
I. Real world scenario
Until now, GS has run his shop on a computer system created by a university student 5 years
ago. The system is currently too slow and since no system documentation is created during
development it is difficult to make improvements. GS executives believe that in order to
successfully grow and operate their store, they must adapt as their business needs evolve.

II. Data requirement for storage

1. User
Entity Description Attribute Descriptio of
attribute
Id_user Id of user
Name User name
User Phone User phone number
Email User email
Pass User pass
Address User Address

2. Staff
Entity Description Attribute Descriptio of
attribute
Id_staff Id of staff
Staff Name Staff name
Phone Staff phone number
Email Staff email
Pass Staff pass

3. Type
Entity Description Attribute Descriptio of
attribute
Type Id_type Id of type
Name Name type

4. Manufacturer
Entity Description Attribute Descriptio of
attribute
Manufacturer Id_manufacturer Id of manufacturer
Name Name manufacturer

5. Warehouse
Entity Description Attribute Descriptio of
attribute
Warehouse Id_warehouse Id of warehouse
Name Name warehouse

6. Product
Entity Description Attribute Descriptio of
attribute
Id_product Id of product
Id_type Id of type
Product Id_manufacturer Id of manufacturer
Id_warehouse Id of warehouse
Name Product name
Price Product price

7. Orders
Entity Description Attribute Descriptio of
attribute
Id_orders Id of orders
Staff Id_user Id of user
Id_staff Id of staff
Date Order date
Total Total price

8. Ordersdetail
Entity Description Attribute Descriptio of
attribute
Id_orders Id of order
Ordersdetail Id_product Id of product
Amount The number of
products
Price Product price

III. Relationship between entities


One staff manages multiple orders, one order is managed by one staff.

A user has many orders, and an order belongs to only one user.

An order has only one order detail and vice versa.

A product has many order details, an order detail has only one product.

A product has one type, a category can have many products.

A product belongs to a manufacturer, a manufacturer can have many products.

A product is stored in a warehouse, a warehouse can contain many products.

C. DATABASE DESIGN
I. ER Diagram
1. What is ER diagram?
The Entity Relationship model (E-R) introduced by CHEN in 1976 is a widely used
model in conceptual database designs, built on the recognition of real world knowledge
through a set of objects called entities and the relationships between these objects.
Compared with the network model, the entity-relationship model has more advantages
and it shows more clearly the components in the real world. If the network model only
represents the main objects but not the features in that object, the entity-relationship
model overcomes these weaknesses. Therefore, the choice of this model is always the
decision of the database design analyst.

2. Role of ER Diagram in database design process:


The goal of the ER Diagram in the database design process is to analyze the data,
identifying the basic units of information needed by the organization. , describe the
structure and the relationship between them.
ER is an intermediary model for translating real-world data management requirements
into a relational database model.

3. Basic components of ER Diagram


i. Entities and Entity Sets
Entity is a real-world object.
A group of similar entities constitutes an entity set
The selection of entity sets is an extremely important step in building an entity
relationship diagram
Example: “Manage company projects”
• An employee is an entity
• The set of employees is the entity set
• A project is an entity
• The set of projects is the entity set
• A department is an entity
• The set of departments is the entity set

ii. Attributes:
Each entity set has a set of characteristic properties, each of which is called an
attribute of the entity set. For each attribute there is a set of values for that attribute
called the value domain.
The attribute's value domain includes the following value types:
• String Type
• Integer type
• Real number type (real)
• ...

Attributes include the following types:

• Single attribute – cannot be subdivided


• Complex properties – can be broken down into smaller components

Attribute value types:

• Monovalues: attributes with unique values for an entity (eg ID number, ...)
• Multivalued: attributes that have a set of values for the same entity (e.g.
degree, ...)
• Deductible (year of birth <----> age)

Each entity is distinguished by the key attribute

iii. The relationship between entity sets:


A relationship is an association between two or more entity sets
For example, between the entity set NHANVIEN and PHONGBAN, there are the
following associations:
• An employee of a certain department
• A department has one employee as the head of the department
• A relation set is a collection of similar relationships

iv. ER Diagram
A graph that represents sets of entities, attributes, and relationships
Example ER Diagram:
v. Link types in ER Diagram:

vi. Key properties:


Each entity set must have a key.
A key can have one or more attributes.
There can be many keys in an entity set, we will choose 1 key as the primary key for
that entity set.

4. Build ER Diagram
i. Rule:
• Exactly
• Avoid duplicates
• Easy to understand
• Choose the right relationship
• Choose the right attribute type

ii. Build steps:


• List and select information
• Identify the entity set
• Identify the relationship
• Define attributes and assign attributes to entity sets and relationships
• Decide on the key attribute
• Draw an entity model diagram E-R
• Normalize the chart
5. Software that supports drawing ER Diagram
Some tools features to draw ERD:
i. DeZign for Databases:

• Drag-and-drop user interface


• Entity Relationship Diagramming
• Multiple display modes
• Industry-standard design notations
• Multiple display modes
• Pan and zoom window
• ER-Modeling
• Forward engineering
• Reverse engineering

ii. Gleek.io

• Keyboard-based user interface


• Rapid Diagramming
• Version Control
• Live Collaboration
• Diagram export
• Design templates
• Customization
iii. dbdiagram.io

• Generates SQL statements


• Exports to images and PDFs
• One-click sharing
• Integrates with SQL databases

iv. ERDPlus

• User-friendly interface, easy to use


• Full EDR vẽ drawing features
• Very convenient to use can draw right on the website:
https://erdplus.com/
Through the above features, I use ERDPlus to draw Diagram to Relation
Diagram.

II. Convert from associative entity diagram to relational schema.


1. Relational schema
is a set of all relational schemas in the database. The database schema is less likely to change
over time.

2. Convert from ER Diagram to Relational Diagram.


i. Relations
• Order management staff
• User owns the order
• Orderdetail is the detail of the order
• Manufacturers and distributors of products
• Product warehouse
• Type of product classification

ii. The oath shows the link between the relations

Staff (id_staff, name, phone,…)

User (id_user, name, phone,…)

Orders (id_orders, id_staff, id_user,…)

Ordersdetail (id_orders, id_product,…)

Product (id_product, id_type, id_manufacturer, id_warehouse,…)

Type (id_type, name)

Manufacturer (id_manufacturer, name)

Warehouse (id_warehouse, name)


iii. Detailed settings

Staff
NO Attribute Describe Datatypes Size Constraint
name
1 Id_staff Id of staff INT 11 Not null,
Primary
key
2 Name Name of Varchar 45 Default
staff null
3 Phone Phone of Varchar 45 Default
staff null
4 Email Email of Varchar 45 Default
staff null
5 Pass Pass of Varchar 45 Default
staff null
Manufacturer
NO Attribute name Describe Datatypes Size Constraint
1 Id_manufacturer Id of INT 11 Not null,
manufacturer Primary
key
2 Name Name of Varchar 45 Default
manufacturer null

Type
NO Attribute name Describe Datatypes Size Constraint
1 Id_type Id of type INT 11 Not null,
Primary
key
2 Name Name of type Varchar 45 Default
null

Warehouse
NO Attribute name Describe Datatypes Size Constraint
1 Id_warehouse Id of INT 11 Not null,
warehouse Primary
key
2 Name Name of Varchar 45 Default
warehouse null

User
NO Attribute Describe Datatypes Size Constraint
name
1 Id_user Id of user INT 11 Not null,
Primary
key
2 Name Name of Varchar 45 Default
user null
3 Phone Phone of Varchar 45 Default
user null
4 Email Email of Varchar 45 Default
user null
5 Pass Pass of user Varchar 45 Default
null
6 Address Address of Varchar 45 Default
user null

Product
NO Attribute name Describe Datatypes Size Constraint
1 Id_product Id of user INT 11 Not null, Primary key
2 Id_type Id of type INT 11 Default null, FK(type)
3 Id_manufacturer Id of INT 11 Default null
manufacturer FK( manufacturer)
4 Id_warehouse Id of warehouse INT 11 Default null,
FK(warehouse)
5 Name Product name Varchar 45 Default null
6 Price Address of user Varchar 45 Default null

Orders
NO Attribute name Describe Datatypes Size Constraint
1 Id_orders Id of orders INT 11 Not null, Primary key
2 Id_user Id of user INT 11 Default null, FK(user)
3 Id_staff Id of staff INT 11 Default null
FK(staff)
4 Date Order date Date Default null,
5 Total Total price Varchar 45 Default null

Ordersdetail
NO Attribute name Describe Datatypes Size Constraint
1 Id_orders Id of orders INT 11 Default null, FK(orders)
2 Id_product Id of product INT 11 Default null, FK(product)
3 Amount The number of Varchar 45 Default null
products
4 Price Product price Varchar 45 Default null,

iv. Database Diagrams

III. Normalization
1. The goal of standardization
▪ Eliminate data redundancy
▪ Remove update anomaly
▪ Remove insertion anomaly
▪ Remove deletion anomaly

2. Nomalization divided into what type


i. 1NF (First Nomal Form)
• A table (relation) is said to be in 1NF normal form if and only if
all the domains of the columns present in the table (relation)
contain only atomic (prime) values.

ii. 2NF
• Is 1NF
• Non-key attributes must be fully functionally dependent on the
primary key

iii. 3NF
• Is 2NF
• Non-key attributes must depend directly on the primary key

IV. Relational database system


1. Design Database.
A database management system (DBMS)
DBMS is a software package designed to define, manipulate, retrieve, and manage data in
a database. The DBMS usually manipulates its own data. Data format, field names, record
structure, and file structure. It also defines rules for validating and manipulating these data
The most popular database management systems today:

Oracle
Advantages:
• There will be improvements and new features. Because Oracle tends to set the bar
for other database management tools.
• Oracle's database management tools are also extremely powerful. You might find a
tool that can do what you want.
Disadvantages:
• The cost of Oracle is quite high, especially for small organizations.
• The system will require quite a lot of resources after installation. So it is necessary
to upgrade the hardware

SQL Server
Advantages:
• It is very fast and has stability.
• Provides performance tuning and monitoring capabilities. Reduces the use of
resources.
• Visualization is accessible on mobile devices.
• Works well with other Microsoft products.
Disadvantages:
• Even with performance throttling, Microsoft SQL Server can consume resources.
• Many individuals have problems using SQL Server integration services to import
files.

MySQL
Advantages:
• Free version available.
• Provides many functions.
• Various types of user interfaces.
• It can work on other databases like DB2 and Oracle.
Disadvantages:
• You need to spend a lot of time working with MySQL (which other systems will do
automatically).
• Support will be available in the free version but you need to pay for it.
• Conclude: From the above priority points, we will choose the site using MySQL to
deploy the project's database.

❖ Create database and attached tables


Figure 1 Create database
2. Implement a query language
Hình 2 Before update

Hình 3 After update

Hình 4 Before delete


Hình 5 After delete

D. Test
No Test Error Fix Result
1 Update product Set price = Unknown Change from Pass
600000 Where id =1 column 'ID' in "id=1" to
'where clause' "id_product=1"
2 INSERT INTO Incorrect date Change from Pass
`glass_shop`.`orders` value: '25-6- "25-6-2022" to
(`id_orders`, `id_user`, 2022' for column "2022-06-25"
`id_staff`, `date`, `total`) 'date' at row 1
VALUES ('01', '01', '01', '25-
6-2022', '500000')

E. SYSTEM SECURITY AND MAINTAINACE

Trigger

A trigger (from the Dutch trekken, meaning to pull) is a lever which, when pulled by the
finger, releases the hammer on a firearm. In a database, a trigger is a set of Structured Query
Language (SQL) statements that automatically "fires off" an action when a specific
operation, such as changing data in a table, occurs.
What is the function of a trigger?
Creating a response to an event is done with a trigger. A trigger is a declaration that you are
interested in a certain event or set of events. Binding a function to a trigger allows you to
capture and act on events.

F. TECHNICAL AND USER DOCUMENT


1. MySQL Workbench for design Database
The visual SQL Editor lets developers build, edit and run queries, create and edit data, and
view and export results. Color syntax highlighting, context sensitive help and auto-complete
aids in writing and debugging SQL statements. And EXPLAIN plans can easily be gathered
to help optimize queries. The SQL Editor provides:

• Table Editor - easily edit data and commit changes using a simple grid format.
• Results Window - execute multiple queries simultaneously and view text results,
image and spatial views, and query performance statistics on individual tabs.
• SQL Snippet Panel - save and easily reuse common Selects, DML and DDL code.
• History Panel - view complete session history of queries and statements showing
what queries were run and when. Easily retrieve, review, re-run, append or modify
previously executed SQL statements.
• Table Data Search Panel - find data across an entire database by proving text search
on any number of tables and schemas, showing rows matching a given pattern.
• Export Results - export results data to common formats including CSV, HTML, and
XML.
Object Management

The Object Browser enables developers to easily navigate database schemas and objects.
DBAs can visually select tables and fields to query, edit tables, create new tables and
databases, and drop tables and databases.
Schema Inspector - Leverage a suite of detailed grids on all objects in their database
schemas to view, sort, and analyze various details and statistics. From within Schema
inspector developers can easily invoke table maintenance operations such as ANALYZE
and OPTIMIZE TABLE.

Object Browser - Easily navigate, explore, and perform actions on database objects
(tables, views, triggers, etc.)

Object Editor - Easily edit, create or delete database objects (tables, views, triggers, etc.)

Connection Management

The Database Connections Panel and Connections Wizard enables developers to create,
organize, and manage standard database connections, including MySQL Fabric.
Advanced users can use the Manage Connections dialog to enter connection parameters
like IP address, port, username, and password, as well as easily create secure remote
connections via ssh.

2. Install MySQL and MySQL Workbench.

Visit the link to download the MySQL community version:


https://dev.mysql.com/downloads/windows/installer/8.0.html
G. REFERENCES
Install MySQL and MySQL Workbench. (n.d.). Stackjava. Retrieved June 25, 2022, from
https://stackjava.com/install/mysql-la-gi-cai-dat-mysql-mysql-workbench-tren-window.html
SQL Tutorial. (n.d.). W3school. Retrieved June 25, 2022, from https://www.w3schools.com/sql/
What is. (n.d.). Thinhnotes. Retrieved June 25, 2022, from https://thinhnotes.com/chuyen-nghe-
ba/erd-la-gi/

You might also like