Assignment Database
Assignment Database
Internal verification:
I. INTRODUCTION
- A database, in the most general sense, is an organized collection of data. More
specifically, a database is an electronic system that allows data to be easily accessed,
manipulated, and updated.
In other words, an organization uses a database as an electronic way to store, manage and
retrieve information. The database is one of the cornerstones of enterprise IT, and its
ability to organize, process, and manage information in a structured and controlled
manner is the key to many aspects of modern business efficiency.
However, databases go way beyond simply storing data. As we’ll see later, the inherent
logic and efficiency in how the data is stored and retrieved can provide an incredibly
powerful business tool to an organization. This is especially true when databases are
properly exploited for their reporting and business intelligence capabilities.
II. THEORY
1. Database
1.1. A database:
- Is an organized collection of structured information, or data, typically stored
electronically in a computer system. A database is usually controlled by a database
management system (DBMS). Together, the data and the DBMS, along with the
associated applications, are referred to as a database system, often shortened to just a
database (Oracle, 2020).
2. Relational database
2.1 What is a relational database?
The concept of a relational database was first mentioned in 1970 by British computer
scientist E. F. Codd. Accordingly, a relational database is a type of database in which data
is related to other information on the database. They are used to store and organize data
with references between two or more sources. Or more simply, a relational database will
consist of a collection of tables accessed and rebuilt in many ways without rearranging the
database tables (Oracle, 2021).
2.2. Components of a relational database:
- Table of data (Table)
Column / Field (Field): represents the properties of the data table such as name,
address...
Row (Row): a data line consisting of related data.
Cell: the intersection between rows and columns, this is where data is stored.
Primary Key: one or more aggregated fields used to define a record table. The
primary key has two attributes, which cannot be null and cannot be duplicated.
Note: A table may or may not have a primary key. But for ease of management,
defining primary keys for tables is common.
- Relationship
Foreign Key: is a field in this table but has a corresponding field as a primary key
in another table to create a relationship between two tables.
Relationship: Creates a relationship between two tables to determine the
relationship between the data fields of the two tables.
In a relational database, relationships usually appear in the following three forms:
One-to-one relationship: each table has only one corresponding record. For
example, husband-wife relationship, basic information relationship - detailed
information...
1-n relation: the most common relationship in the database. In this system, 1 table
in one table has many corresponding records in another table.
n-n relationship: one record in one table corresponds to many records in the other
and vice versa. (Oracle, 2021).
3. Entity Relationship Diagram( ERD)
3.1. Entity Relationship Diagram:
Entity Relationship Diagram abbreviated as ERD represents the relationships of the set of
entities stored in the database. Diagrams assist in explaining the logical structure of the
database. ERD includes many specialized symbols, and its meaning makes this pattern
unique (Nishadha, 2019).
- What is an entity?
+ An entity in DBMS (Database Management System) is a real-world object that has
certain properties called attributes that define the nature of the entity. Entities are
distinguishable, i.e., each entity in a pair of entities has a property that differentiates one
entity from the other.
- What is an entity's attribute?
+ 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.
+ 1 to 1: The 1-1 relationship creates two data files that describe two entities. Define a
primary key field, a description field for each file. The relation field can belong to one file
or the other. In both cases, the information obtained is the same
+ 1 to many: The 1 – many relationships is the relationship where one entity record for
the primary entity can be associated with many other related entity records because of the
lookup field on the related entity.
+ many to many: Many to many relationships the relationship depend on a special
Relationship Entity, sometimes called an Intersection entity, so that many records of one
entity can be related to many records of another entity.
Name Description
Relationship Symbol
Derived
attribute
- Some tools used to draw ERD: Lucid chart, Visual Paradigm, SmartDraw, Creately,
EdrawMax, Dbdiagram, Miro, Datanamic – DeZign for Databases, SqlDBM, dBForge
Studio for SQL Server, Gliffy, Git Mind, Draw.io.
- Tools should be used to draw ERD: Draw.io
-> Reason: draw diagrams online, fast and powerful, free, unlimited quantity (Lucid,
2019).
4. Relational schema
4.1. What is relational schema?
- A relational schema is a blueprint used in database design to represent the data to be
entered into the database and describe how that data is structured in tables (called
relations in relational schemas). The schema describes how those tables relate to each
other.
+ In the relational schema, the table, or relation, consists of a set of named, but unsorted,
columns (called attributes in relational schemas) and an undefined number of unnamed
and unsorted rows (called tuples in relational schemas). Each row is unique, but the rows
can be moved around as needed and stored in any order, modified, or deleted without
impacting the efficient operation of the database (Gleek, 2020).
4.2. Purpose of relational schema
- A relational schema is a blueprint used in database design to represent the data to be
entered into the database and describe how that data is structured in tables (Gleek, 2020).
4.3. How to convert the model to a relational model
- Step 1: Each normal entity type (not a weak entity type) in the ER model becomes a
relation. That relationship includes all the simple and composite attributes of the entity.
The identity attribute of the entity is the primary key to the relationship.
- Step 2: For each Weak Entity in the ER model, forming a relation R, all the simple
attributes of the weak entity become properties of R. In addition, the identity attribute of
the master entity becomes a foreign key of R.
+ The primary key of R is a combination of the identity attribute of the master entity and
the identity attribute of the weak entity.
- Step 3: For each one-to-one relationship in the ER model:
+ Define a relation S_T. Entity type with full participation in the association becomes
relation S, the other entity type becomes relation T.
+Make T's primary key a foreign key of S.
The attribute of the relation S_T becomes an attribute of S.
- Step 4: For each 1_N association in the ER model. Convert the primary key of the 1 side
relation to the foreign key of the N side.
- Step 5: For each association MN, generate a new relation R, converting the primary key
of the two relations M and N into the foreign key of the relation R. The primary key of R
is the combination of the two foreign keys.
- Step 6: If there is a multivalued attribute
Convert multivalued attributes to a new relation.
+ The identity attribute (or part of the identity attribute) of the primary entity is converted
to the foreign key of the new relation.
+ The primary key of the new relationship is the primary key of the relation itself + the
foreign key passed by the primary entity.
- Step 7: For each association of degree (>2), create a new relation (R), the primary key of
the joining relations is given as the foreign key of the relation R, and these foreign keys
also play the role of is the primary key of R.
- Step 8: Dealing with parent/child relationships and specialization or generalization.
Different options for converting several subclasses from the same specialization (or
generalization to the superclass). In addition to the 7 steps described above step 8 below
gives the most common choice and the conditions under which each option can be used.
Use the notation Attr(R) to represent the attributes of R, and PK(R) is the primary key of
R. (MSc. Pham Hoang Nhung, 2017)
5. Relational database management system
5.1. What is RDBMS?
- A relational database management system (RDBMS) is a program used to create,
update, and manage relational databases. Some of the most well-known RDBMSs include
MySQL, PostgreSQL, MariaDB, Microsoft SQL Server, and Oracle Database. (Google
Cloud,2019)
6. Standardized data
6.1. Database normalization
Normalization is the process of splitting a table (decaying) into smaller tables based on
functional dependencies. Standard forms are guidelines for designing tables in a database.
- The purpose of normalization is to eliminate data redundancy and redundancy
manipulation errors and data manipulation errors (Insert, Delete, Update). But
normalization increases the query time. (Richard Peterson, 2019)
Rule 1: Be in 1NF
Rule 2: Single Column Primary Key that does not functionally dependent on any subset of
candidate key relation
Membership ID Movies
1 My love
1 Sherlock Holmes
1 On Your Wedding Day
2 Clash of the Titans, Harry Potter
2 Harry Potter
3 Minions
+ Rule 1: Be in 2NF
Rule 2: Has no transitive functional dependencies
To move our 2NF table into 3NF, we again need to divide our table.
Membership ID Movies
1 My love
1 Sherlock Holmes
1 On Your Wedding Day
2 Clash of the Titans, Harry Potter
2 Harry Potter
3 Minions
Salutation ID Salutation
1 Mr.
2 Mrs.
3 Ms.
4 Dr.
+ Even when a database is in the 3rd Normal Form, there would still be anomalies if it has
+ more than one Candidate Key.
+ If no database table instance contains two or more, independent and multivalued data
describing the relevant entity, then it is in the 4th Normal Form.
- 5NF ( Fifth Normal Form) Rules: A table is in 5th Normal Form only if it is in 4NF and
cannot be decomposed into any number of smaller tables without data loss.
+ 6th Normal Form is not standardized, however, it is being discussed by database experts
for some time. Hopefully, we would have a clear & standardized definition for the 6th
Normal Form shortly... (Richard Peterson, 2019)
- SQL is used for the following: modifying database table and index structures; adding,
updating, and deleting rows of data; and retrieving subsets of information from within
relational database management systems (RDBMSes) -- this information can be used for
transaction processing, analytics applications, and other applications that require
communicating with a relational database. (David, 2020)
- CREATE
Syntax:" CREATE DATABASE database name;"
- USE
Syntax: " USE database name; "
- SELECT
Syntax: "SELECT * FROM table_name; Or SELECT column1, column2, ... FROM
table_name;"
- DROP
Syntax: " DROP database name; "
- WHERE
Syntax: "SELECT column1, column2, ... FROM table_name WHERE condition;"
- INSERT INTO
Syntax:" INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1,
value2, value3, ...);"
-UPDATE
Syntax: UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE
condition;
- DELETE
Syntax: DELETE FROM table_name WHERE condition;
- JOINS
Syntax: SELECT column_name(s) FROM table1
INNER/LEFT/RIGHT/FULL/CROSS JOIN table2 ON table1.column_name =
table2.column_name; (viblo, 2019)
- ALTER TABLE
Syntax: ALTER TABLE table_name ADD column_name datatype;
8. System Testing
8.1. What is System Testing?
- System Testing is a level of testing that validates the complete and fully integrated
software product. The purpose of a system test is to evaluate the end-to-end system
specifications. Usually, the software is only one element of a larger computer-based
system. Ultimately, the software is interfaced with other software/hardware systems.
System Testing is defined as a series of different tests whose sole purpose is to exercise
the full computer-based system. (Hamilton, 2019)
III. PRACTICE
1. Analyze real problems, the database information needs to be stored
- Problem analysis:
- BKC is one of the IT companies in Vietnam that has been hired by HirePhone – a
mobile phone retail chain – to develop software called “HirePhone Store”, which helps
manage and sell phone products for their retail chain. Customers need to know the
basic information of each phone such as IMEI, name of the phone, release date,
capacity, phone size, manufacturer, etc
- You are an employee of BKC company assigned to be in charge of the “Hirephone
Store” software project. Your task is to design and develop the database using the right
design tools and techniques and must test the database according to user requirements.
Finally, you have to provide HirePhone’s owners with technical documentation so
users can see how your database works
2. List of entities
- Phone:
-Salesman:
- Customer:
- Manufacturer
- Comment:
- Shipping Method
- Color:
- Receipt Details:
3. Attributes of entities
- Phone: IMEI, manufacturer, color, price, release_date, chip, ram_capacity,
rom_capacity, length, width, thickness, phone_name.
- Salesman: name, salesman_ID, date_of_birth, address, gender, email, phone_number
- Customer: name, customer_ID, date_of_birth, address, gender, email, phone_number
- manufacturer_name, manufacturer_ID
- shipping_method, customer, salesman, receipt_details,
- Color: color_ID, color_name
- Receipt Details: receipt_ID, code_receit, receipt
- shipping_ID, shipper_name, shipping_brand, shipping_price
4. Relationship of entities
5. ERD
6. Relational schema
Table 1: Color
Table 3: Phone
Table 4: Salesman
Table 5: Customer
Table 7: Receipt
9. Database diagram
10. Query statements used in the generated database (including queries across multiple
tables)
-SELECT*:
-SELECT.. where:
- DELETE:
- SELECT … COUNT:
- ALTER TABLE:
- INNER JOIN:
- FULL JOIN:
11. Normalize created database
- All versions are 3NF because it is standard 2 NF and depends on the primary key of the
table
12. System security, database maintenance
+ Server role
+ Authentication
+ Database role
- Next, select User Mapping and select the Map you want to create Login, below we
select the role we want to log in and click OK to finish Login.
IV. APPLY THE TEST TO THE CREATED DATABASE
1. Test log
Set 1:
Set 2:
Set 3:
- Set 4:
- Set 5:
- Set 6:
- Set 7:
- Set 8:
- Set 9:
- Set 10:
- Set 11:
- Set 12:
- Set 13:
- Set 14:
- Set 15:
2. Test case
TC1 Show a list of Select all users Set 1 Show all Octob OK None
ShippingMeth in the Shipping values er 25,
od Method table ShippingMet 2022
with the query hod
Select
TC2 Add new user Enter data from Set 2 The user was Octob OK None
the data capture stored in the er 25,
sheet into the database 2022
insert
TC3 Update user Update user has Set 3 The user has Octob OK None
a shipper name updated the er 25,
Nguyen Huu Shipper name 2022
Duy where a to Nguyen
shipper ID = 1 Huu Duy
where
shipper ID =1
TC4 Delete user Delete user has Set 4 The user was Octob OK None
shipping ID = 2 deleted where er 25,
shipper ID = 2022
2
TC5 Show a Select the user's Set 5 The user’s Octob OK None
property of the properties where property has er 25,
user in a table a shipping ID = showed 2022
3
TC6 Show all users Select all users Set 6 Show all Octob OK None
with any has shipping users with the er 25,
attribute in the brand = Tiki and given 2022
table shipping price = attribute in
18990000 the table
TC7 Show all Select the user’s Set 7 October 25, OK None None
attributes of properties has 2022
the user with shipping brand
the given = Lazada or
attribute in the shipping price =
table 78000
TC8 Show all users Select all users Set 8 Show all Octob OK None
with 1 pre- who have sorted users had er 25,
sorted properties sorted 2022
attribute
TC9 Show all users Select all users Set 9 Show all Octob OK None
have the with a given users had er 25,
characters in letter in their selected 2022
their properties
properties
TC1 Show all users Select all users Set 10 Show all Octob OK None
0 have with a given users had er 25,
properties condition filtered 2022
with a given
condition
TC1 Show the Select and count Set 12 Show the Octob OK None
2 number of all the number result after er 25,
users of an of users in an counting 2022
entity entity
TC1 Add an Add an attribute Set 13 Show the row Octob OK None
3 attribute to a to an entity has adding er 25,
pre-existing 2022
entity
TC1 create 1 big Select 2 or more Set 14 Show the Octob OK None
4 table with similar attributes total table er 25,
many from the tables after add 2022
attributes to combine to
form a large
table containing
all the selected
attributes.
TC1 create 1 big Select 2 or more Set 15 Show the Octob OK None
5 table with similar attributes total table er 25,
many from the tables after add 2022
attributes to combine to
form a large
table containing
all the selected
attributes.
Step 6: After installing, it will appear as follows, and select Install SSMS
Step 7: Install SSMS will be a downloaded 1 file and here we complete the installation
and can use SQL 2019.
3. Describe how the database system works including data flow diagrams and
flowcharts
+ Design and manage a database to manage and sell phone products to the retail chain.
+ Customers can view basic information about each phone such as IMEI, model name,
release date, capacity, phone size, and manufacturer.
+ The work has completed most of the requested content: customers can view basic
information about each phone such as IMEI, model name, release date, capacity, phone
size, and manufacturer; the seller can manage the phone in a small store.
+ However, to be able to put it into use at a chain of phone stores, there are still many
shortcomings.
2. Evaluate the effectiveness of the database solution regarding user and system
requirements.
- Evaluate whether meaningful data has been extracted through the use of query tools to
generate appropriate management information.
+ Data has been extracted through the use of query tools to generate appropriate
management information
- Explain the selection of data to test into the DB, and evaluate the effectiveness of the
test:
+ Selected data has met the requirements of a strange customer, including IMEI, model
name, release date, capacity, phone size, and manufacturer.
+ The test has met the requirements and expectations of the problem.
+ If you want to use it, you have to improve more about storing customer data in the form
of files, so that you can help the store manage customers in an easier, more scientific, and
more convenient way.
- System Continuity:
+ The most common persistent in a database is a timestamp and the second most common
data types are REAL, FLOAT, and PRECISION DOUBLE. But we cannot represent
continuous values in a calculator. Do we have to approximate them and live with the
errors, model them in the structure of the language or use a programming language to
manipulate them symbolically
+ The other constant in SQL is the timestamp, which is DATETIME2(n) in SQL Server.
The nature of time is very different from real numbers. A dimensionless quantity is a
quantity that has no associated physical space. Time is a dimension to measure the
movement of objects. Time moves and moves in one direction.
Gleek (2020). Diagram maker for developers. [online] www.gleek.io. Available at:
https://www.gleek.io/blog/relational-schema.html.
Google Cloud (2019). What Is A Relational Database (RDBMS)? [online] Google Cloud.
Available at: https://cloud.google.com/learn/what-is-a-relational-database#:~:text=A
%20relational%20database%20management%20system [Accessed 10 Oct. 2022].
Hamilton, T. (2019). What is System Testing? Types & Definition with Example. [online]
Guru99.com. Available at: https://www.guru99.com/system-testing.html.
Henry (2019). Tìm hiểu về SQL ngôn ngữ truy vấn có cấu trúc. [online] viblo.asia.
Available at: https://viblo.asia/p/tim-hieu-ve-sql-ngon-ngu-truy-van-co-cau-truc-
bJzKmwr6l9N.
PACISOFT (2020). 10 Lý do chọn Microsoft SQL Server 2019. [online] Trung tâm trợ
giúp - PACISOFT Help Center. Available at:
https://help.pacisoft.com/knowledgebase/10-ly-do-chon-sql-server-2019/#:~:text=SQL
%20l%C3%A0%20ng%C3%B4n%20ng%E1%BB%AF%20phi [Accessed 10 Oct. 2022].
Richard Peterson (2019). What is Normalization? 1NF, 2NF, 3NF & BCNF with
Examples. [online] Guru99.com. Available at: https://www.guru99.com/database-
normalization.html.
Sharma, L. (2019). What is System Testing? Its Objectives, Test Basics and Test Objects.
[online] TOOLSQA. Available at:
https://www.toolsqa.com/software-testing/istqb/system-testing/.
Ths. Phạm Hoàng Nhung) (2017). Cơ sở dữ liệu: Chuyển từ mô hình ER sang mô hình
quan hệ - VOER. [online] voer.edu.vn. Available at: https://voer.edu.vn/c/chuyen-tu-mo-
hinh-er-sang-mo-hinh-quan-he/d11e79e2/3a0b6c88 [Accessed 10 Oct. 2022].