F - Database Assignment
F - Database Assignment
ASSIGNMENT NUMBER: 1
1
Summative Feedback:
You achieved: P3, P4
Strengths:
- You have given the concept, role, importance of database and some types of database.
- You have demonstrated the concept of a relational database and its components.
- You have given the concept, the purpose of the entity relationship diagram.
- You have shown the components of the entity-relationship diagram.
- You have presented the concept and purpose of relational schema.
- You showed how to convert from ERD to relational schema.
- You have introduced the concept and role of the DBMS.
- You have given a number of database management systems and made a conclusion which
RDBMS to choose to apply to the software.
- You presented the concept of database normalization.
- You have demonstrated the concept of query language and statements in query language.
- You have presented the concept of system testing and its purpose.
- You have analyzed the actual problem, the database information needs to be stored.
- You have given a list of entities and their attributes.
- You have given the relationship of entities and ERD diagram, DB Diagram.
- You have given the list of tables present in the DB.
- You have entered the query statements used in the created database.
- You have applied the test to the created DB.
Weakness:
- Complete the sections listed in the "Weakness" section to achieve the basic criteria of the
assignment.
- You need to review how to convert from ERD to relational schema to match what was
analyzed.
- You must present the file according to the given template standard.
Grade: Fail
Date: November 01, 2022
Assessor: Nguyen Phuong Hai
2
Internal verification:
3
Contents
I. Introduction .................................................................................................................................. 5
II. Theory ......................................................................................................................................... 5
1. Database ...................................................................................................................................... 5
a. Definition ............................................................................................................................. 5
b. Purposes of Database .......................................................................................................... 6
c. Roles and the importance of database ................................................................................. 6
d. Types of databases .............................................................................................................. 8
2. Relational Database ................................................................................................................... 12
a. Definition ........................................................................................................................... 12
b. Components of a relational database ................................................................................. 12
3. Entity relationship diagram (ERD) ........................................................................................... 14
a. Definition ........................................................................................................................... 14
b. Purposes of ERD ............................................................................................................... 14
c. Components of an ERD ..................................................................................................... 14
d. Tools to draw an ERD ....................................................................................................... 16
4. Relational schema ..................................................................................................................... 16
a. Definition ........................................................................................................................... 16
b. Purposes of database schemas ........................................................................................... 19
c. Convert ERD into relational schema ................................................................................. 20
5. Relational Database Management System (RDBMS) .............................................................. 20
a. Definition and uses ............................................................................................................ 20
b. Different RDBMS(s) ......................................................................................................... 20
6. Database normalization ............................................................................................................. 22
a. Definition ........................................................................................................................... 22
b. Types of database normalization ....................................................................................... 23
7. Structured Query Languages ..................................................................................................... 25
a. Definition ........................................................................................................................... 25
b. Statements in SQL ............................................................................................................. 25
8. System Testing .......................................................................................................................... 29
a. Definition ........................................................................................................................... 29
b. Purposes ............................................................................................................................ 29
References ..................................................................................................................................... 31
III. Practice .................................................................................................................................... 32
4
1. Analyze the problem ................................................................................................................. 32
2. Entity list ................................................................................................................................... 32
3. Entity Properties ........................................................................................................................ 32
4. Relationships of entities ............................................................................................................ 33
5. ERD ........................................................................................................................................... 34
6. Relational schema ..................................................................................................................... 34
7. Constraints ................................................................................................................................. 35
8. Detail settings ............................................................................................................................ 35
9. DB Table ................................................................................................................................... 35
10. Query statements in the created database ................................................................................ 36
11. Normalized database ............................................................................................................... 38
12. System security, database maintenance .................................................................................. 39
IV. Test log and test case .............................................................................................................. 39
I. Introduction
BKC is a Vietnamese IT company that has been hired by HirePhone –
a mobile phone retail chain – to develop a software called “HiredPhone
Store”, which helps to manage and sell phone product for their retail
chain. Customers need to know the basic information of each phone
such as IMEI, name, release date, RAM and ROM capacity, phone size,
manufacturer, etc. As an employee of the company, I am assigned of
this project. To be able to fully understand how an apps is developed, I
took further research into the database of apps developing process. In
this document, I will cover findings from research into database,
relational database, entity relationship diagram, relational schema,
Relational Database Management System, database normalization,
Structured Query Languages and system testing.
II. Theory
1. Database
a. Definition
A database is a structured collection of information or data that is often
kept electronically in a computer system. A database management
system is generally in charge of a database (DBMS). The data and the
DBMS, along with the applications that are linked with them, are
5
together referred to as a database system, which is frequently
abbreviated to just database.
b. Purposes of Database
A database is used to store and organize data.
- Secure data
Because it saves all of the data in the form of tables, records, and files,
the database makes it easy to discover what you're looking for and keep
related data in one place. It also captures data in rows and columns for
quick access to the precise information you want at any given time.
6
Moreover, databases enable searches for particular information that are
not available with paper-based solutions.
- Reliability
- Easy to Use
Databases are simple to utilize. They are available from any computer
that has an internet connection. This enables you to quickly and easily
obtain the information you want when you need it. Furthermore, many
databases offer user-friendly interfaces that make them simple to
understand and apply.
You may store each item in your inventory and retrieve this information
at any moment by using a database. This makes it easy to find each item
if your computer systems or office location are down.
Even if numerous people are working in the system at the same time,
the database guarantees data integrity by presenting you with reliable
information. When there is a data dispute, the database automatically
selects one version over another to ensure that only correct information
is preserved. This ensures that you always have access to high-quality
information, even when there are several users.
7
- Database is portable
d. Types of databases
Different tasks require different types of databases. Here are some
common types of databases.
Centralized Database
Centralized database is a database that saves information in a
centralized database system. It provides customers with the
convenience of accessing saved data from several places via different
applications. These programs have an authentication method that
*Advantages:
- Less expensive
*Disadvantages
- It is difficult to upgrade.
Distributed Database
In distributed system, data is disseminated throughout an organization's
many database systems. These database systems are linked together
8
through communication connections. These connections make it easier
for end users to obtain data.
*Advantages
- A single server failure will not affect the entire data collection.
Relational Database
These databases, together with their administration systems, are
considered the most mature of all databases. Every item of information
in this database is related to every other piece of information. This is
because each data item in the database has a distinct identity in the form
of a record.
In this paradigm, all data is tallied. As a result, each row of data in the
database is connected to another row through a primary key. Similarly,
one table is linked to another using a foreign key.
9
“There are following four commonly known properties of a relational
model known as ACID properties, where:
NoSQL Database
Non-SQL/Not Only SQL databases are used to store a broad variety of
data sets. It is not a relational database since it stores data in several
formats other than tabular. It arose as the demand for developing
contemporary applications expanded. As a result, in response to the
10
- Graph Databases: These databases are used to store large volumes of
data in a graph-like form. The graph database is most typically used by
social networking websites.
*Advantages
- High scalability
Cloud Database
Cloud Databases are databases that store data in a virtual environment
and run on the cloud computing platform. It gives customers access to
the database using various cloud computing services (SaaS, PaaS, IaaS,
and so on).
Object-oriented Database
The sort of database that stores data in the database system using the
object-based data model method. Data is represented and saved as
objects similar to those used in object-oriented programming
languages.
Hierarchical Database
It is a database that holds information in the form of parent-child
relationship nodes. It arranges data in a tree-like form.
11
Data is stored in the form of records that are linked together. Inside this
tree, each kid record will have just one parent. Each parent record, on
the other hand, might have many child records.
Network Database
The network data model is often followed by the database. The data is
represented here as a network of nodes linked together by connections.
In opposed to a hierarchical database, it permits each record to have
several children and parent nodes, resulting in a generalized graph
structure.
Personal Database
Personal Database is designed for one single user. Personal Database is
basically collecting and storing data on the user's system.
Operational Database
The sort of database that collects and updates data in real time. It is
mainly aimed for the execution and management of everyday data
operations in a variety of industries.
2. Relational Database
a. Definition
“A relational database is a collection of information that organizes data
in predefined relationships where data is stored in one or more tables
(or "relations") of columns and rows, making it easy to see and
understand how different data structures relate to each other.
Relationships are a logical connection between different tables,
established on the basis of interaction among these tables.” (What is a
relational database?)
TABLE
A data table is an essential component of a relational database. A table
includes:
12
- Primary key: One or more aggregated fields are utilized to specify a
record table as the primary key. The main key has two properties that
Relationship
Forms of relationships
13
3. Entity relationship diagram (ERD)
a. Definition
ERD is a diagram, showing the entities in the database, and the
relationship between them.
b. Purposes of ERD
- Visualizes the system’s structure
c. Components of an ERD
Entity: A real-world thing, whether it exists or not, that may or may
not be recognized. Anything in an organization that can be represented
in a database qualifies. It could anything. A place, person, object, event,
or concept may all be entities in a database. Entities must have an
attribute and a key attribute. Every entity is made up of some kind of
attribute that represents it.
Entity relationships
14
Symbols of components in an entity-relationship diagram
15
d. Tools to draw an ERD
Draw.io
Draw.io is a free and the best tool for creating diagrams both online and
offline with the following important features:
- Easy to use
Paint
- Easy to use
CONS:
4. Relational schema
a. Definition
An assortment of linked data files or structures makes up a database. It
is made to satisfy the organization's diverse information demands.
Additionally, it is shared and integrated. An arrangement of connection
states that ensures that each relational database state satisfies the
integrity requirements placed on a relational data schema is called a
relational database schema.
16
Star schema
The heart of the star schema is a fact table, with numerous dimensional
tables connecting to it. Star schemas make vast volumes of data easier
to query, aggregate, and use for business intelligence and analytics.
They are useful if you need to arrange a huge collection of raw data or
if you are rebuilding a large data mill or data warehouse.
Snowflake schema
Snowflake schema, like star schema, has a fact table at the center and
numerous dimension tables that connect to it. The main difference
between the two is that in a snowflake schema, dimension tables are
connected to normalized tables.
Relational model
17
Relational databases are usually seen as a collection of entities, some of
which are related to one another in specific ways. It's critical to consider
them as distinct, concrete creatures.
Network Model
When one data item corresponds to many categories, the network model
is applied. A root table links to several child tables in a database's
network model, and each child table can connect to multiple additional
tables. Each child table can have several parent tables, enabling for the
retrieval of numerous connected bits of data for analysis.
Hierarchical model
18
A root table (or segment) connects numerous tables in a hierarchical
structure. Each table can have numerous child tables, but only one
parent table per child table.
Flat model
For simple, small database, flat model is widely used. In flat model
database, there are multiple tables with multiple records, but the tables
do not relate to each other, i.e., they exist in isolation. It can also just be
a single file containing only one table with rows of data separated by
commas or tabs. (Wang, 2022)
19
c. Convert ERD into relational schema
Step 1: Create an appropriate relation type for each entity type
- 1-N associations take the side key of multiple entities and convert it
to a foreign key
b. Different RDBMS(s)
The number of RDBMS is enormous, but here are some of the most
widely used ones.
MySQL
* Features
- High performance
- High availability
20
- Strong support for transactions - a unit of processing in SQL,
consisting of a group of statements for sequential processing of
database operations
- Easy management
- Reasonable cost
* Features
Oracle Database
* Features
- Consistency
- Portability
- Self-managed database
- Resource management
- Data Mining
- Partitions
- Bitmap index
6. Database normalization
a. Definition
The process of reorganizing a relational database in line with a set of
so-called normal forms in order to eliminate data redundancy and
improve data integrity is known as database normalization.
22
b. Types of database normalization
The database normalization process is categorized into many types:
For example:
FULL GENDER PHYSICAL PHONE
NAME ADDRESS NUMBER
Nguyen Van A Male 2nd Street 12 0946178346
Nguyen Van A Male 2nd Street 12 0357312649
Nguyen Thi B Female 3rd Street 12 0956588463
Nguyen Thi B Female 3rd Street 12 0943648235
Nguyen Thi C Female 5th Main Street 0346584718
- Must be in 1 NF
- Single Column Primary Key that does not functionally dependent on
any subset of candidate key relation
For example:
CUSTOMERS’ FULL NAME GENDER PHYSICAL
ID ADDRESS
1 Nguyen Van A Male 2nd Street 12
2 Nguyen Thi B Female 3rd Street 12
3 Nguyen Thi C Female 5th Main Street
Table 1
We have divided our 1NF table into two tables viz. Table 1 and Table2.
Table 1 contains customers’ physical information. Table 2 contains
information on their phone numbers.
- Be in 2NF
23
- Has no transitive functional dependencies
To move our 2NF table into 3NF, we again need to again divide our
table.
CUSTOMERS’ FULL NAME PHYSICAL GENDER
ID ADDRESS ID
1 Nguyen Van A 2nd Street 12 1
rd
2 Nguyen Thi B 3 Street 12 2
th
3 Nguyen Thi C 5 Main Street 2
Table 1
We have again divided our tables and created a new table which stores
GENDER. There are no transitive functional dependencies, and hence
our table is in 3NF. In Table 3 GENDER ID is primary key, and in
Table 1 GENDER ID is foreign to primary key in Table 3
24
7. Structured Query Languages
a. Definition
It is a programming language developed for managing data in a
relational database management system (RDBMS) or for stream
processing in a relational data stream management system (RDSMS).
It is especially beneficial when dealing with structured data, which
includes relationships between entities and variables.
b. Statements in SQL
The SQL CREATE DATABASE Statement
database.
25
The DROP TABLE statement is used to drop an existing table in a
database.
The ALTER TABLE statement is also used to add and drop various
constraints on an existing table.
The SELECT statement is used to select data from a database. The data
returned is stored in a result table, called the result-set.
The WHERE clause can be combined with AND, OR, and NOT
operators.
26
The AND and OR operators are used to filter records based on more
than one condition:
2. If you are adding values for all the columns of the table, you do not
need to specify the column names in the SQL query. However, make
sure the order of the values is in the same order as the columns in the
table. Here, the INSERT INTO syntax would be as follows:
27
The DELETE statement is used to delete existing records in a table.
SQL Aliases
SQL JOIN
A JOIN clause is used to combine rows from two or more tables, based
on a related column between them.
The INNER JOIN keyword selects records that have matching values
in both tables.
The LEFT JOIN keyword returns all records from the left table (table1),
and the matching records from the right table (table2). The result is 0
records from the right side, if there is no match.
28
The RIGHT JOIN keyword returns all records from the right table
(table2), and the matching records from the left table (table1). The result
is 0 records from the left side, if there is no match.
The FULL OUTER JOIN keyword returns all records when there is a
match in left (table1) or right (table2) table records.
A self join is a regular join, but the table is joined with itself.
(W3Schools, n.d.)
8. System Testing
a. Definition
System testing is the process of validating the entire and fully integrated
software product. System Testing means testing the system as a whole.
All the modules/components are integrated in order to verify if the
system works as expected or not.
b. Purposes
- Assure that goods conform to quality requirements.
29
- Testing a software product from to the end helps avoid system errors
and issues when installation in a real setting.
30
References
(n.d.). Retrieved from Oracle:
https://docs.oracle.com/cd/B19306_01/server.102/b14220/intro.htm
Wang, C. (2022, May 31). What is a databse schema? Types and uses
in data integration. Retrieved from Fivetran:
https://www.fivetran.com/blog/what-is-a-database-schema
31
III. Practice
→ One order may have many phones/One customer can have many
orders.
- An order will include its ID, its customer’s information, which store
they ordered at, which staff will handle the order, which warehouse the
phones will come from, which shippers deliver the order, the shipper’s
information and the total price of the order
- Staffs can see what and how many products are left in warehouses.
2. Entity list
- Customers
- Staffs
- Orders
- Warehouses
- Phones
- Shippers
- Stores
3. Entity Properties
- Customers: ID, Name, Phone number, E-mail, Address
32
- Warehouses: ID, Categories, Quantity
4. Relationships of entities
- One customer has many orders
33
5. ERD
6. Relational schema
34
7. Constraints
8. Detail settings
9. DB Table
35
10. Query statements in the created database
36
37
11. Normalized database
38
12. System security, database maintenance
1. Encrypt your data
39
1. Test log
2. Test case
40