0% found this document useful (0 votes)
11 views

F - Database Assignment

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

F - Database Assignment

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

PROGRAM TITLE: HND in Computing

UNIT TITLE: Unit 4: Database Design & Development

ASSIGNMENT NUMBER: 1

ASSIGNMENT NAME: Phone Management System

SUBMISSION DATE: 28/10/2022

DATE RECEIVED: 21/09/2022

TUTORIAL LECTURER: MR. Nguyen Phuong Hai

WORD COUNT: 5525

STUDENT NAME: Nguyen Dac Trung Phuong

STUDENT ID: BKC13093

MOBILE NUMBER: 0934516636

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:

- Your relation schema is not correct with ERD.


- You have given the constraints in the DB incorrectly.
- You made the created database normalization unclear.
- You have not provided technical and user documentation.
- You have not concluded and evaluated the software.
How to improve:

- 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.

To facilitate processing and data querying, data in the most prevalent


types of databases in use today is often structured in rows and columns
in a sequence of tables. After then, the data may be readily accessed,
managed, amended, updated, regulated, and organized. For creating and
querying data, most databases employ structured query language
(SQL).

b. Purposes of Database
A database is used to store and organize data.

c. Roles and the importance of database


 Roles of database

- Organizational data storage.

- Secure data

- Allow multiple users to examine the data at the same time.

- Adaptability to customers’ demands.

- Easy to manage data.

 Why database is important

The database is significant because it helps users to organize and access


data more efficiently. It also allows you to make better choices and
finish projects in less time. Furthermore, a database may assist you
enhance customer service and performance while also allowing you to
communicate with other users.

- Database organizes the 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.

- Database Stores Information Easily

Since databases holds a higher volume of data, they help handle


information more effectively than paper-based filing systems.

It also allows you to quickly and simply add, delete, or modify


information. It aids in keeping your data up to date and accurate.

6
Moreover, databases enable searches for particular information that are
not available with paper-based solutions.

- Reliability

Databases consistently and reliably store data. This aids in the


prevention of data loss.

Even if the data is corrupted, it can be easily restored if it is kept in a


database. However, if the data is saved on paper, retrieving the data may
be difficult or impossible if it becomes damaged or destroyed.

- 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.

- Database allow you to track assets easily

Databases enable corporations and organizations to keep track of their


assets, which is critical for keeping correct records.

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.

- Databases allow you to easily manage a large volume of data

- Your data is secure when it’s kept in a database

Only authorized users have access to the information, preventing


unauthorized people from accessing your sensitive data. To secure data,
databases employ a number of security measures. They often need user
accounts before granting access, and several access specifiers are
offered. It protects you from identity theft and other problems that
might arise as a result of security breaches.

- A database protects data integrity

When it comes to your data, integrity is critical.

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

enables users to safely access data.

*Advantages:

- It reduces the risk of data management by making sure that data


modification does not affect the core data.

- It maintains data consistency by managing data in a central repository.

- It improves data quality

- Less expensive

*Disadvantages

- Large size: The centralized database is enormous in size, which


increases the time it takes to get data.

- It is difficult to upgrade.

- If a server fails, all data is lost.

 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.

A distributed database system can be further categorized into


Homogeneous database and Heterogeneous database:

- Homogeneous database employs the same operating system, the same


application process, and the same hardware devices.

- Heterogeneous database executes on several operating systems using


various application techniques, and carries various hardware devices.

*Advantages

- Supports modular development → expandable

- 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:

A means Atomicity: This ensures the data operation will complete


either with success or with failure. It follows the 'all or nothing' strategy.
For example, a transaction will either be committed or will abort.

C means Consistency: If we perform any operation over the data, its


value before and after the operation should be preserved. For example,
the account balance before and after the transaction should be correct,
i.e., it should remain conserved.

I means Isolation: There can be concurrent users for accessing data at


the same time from the database. Thus, isolation between the data
should remain isolated. For example, when multiple transactions occur
at the same time, one transaction effects should not be visible to the
other transactions in the database.

D means Durability: It ensures that once it completes the operation and


commits the data, data changes should remain permanent.” (Types of
Databases)

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

demands, NoSQL introduced a wide range of database systems. A


NoSQL database may be further classified into the four categories:

- Key-value storage: The most basic sort of database storage since it


keeps each item as a key (or attribute name) and its value together.

- Document-oriented Database: A database that stores data in the form


of a JSON-like document. It aids developers in data storage by
employing the same document-model format as used in application
code.

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.

- Wide-column stores: This type of data is comparable to that found in


relational databases. Instead of storing data in rows, it is stored in huge
columns.

*Advantages

- Not required to store data in a structured format → enables good


productivity in the application development

- High scalability

- Quick access to data through key value

 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?)

b. Components of a relational database

 TABLE
A data table is an essential component of a relational database. A table
includes:

- Column / Field (Field): represents the data table's attributes such as


name, address, etc.

- A row (Row) is a data line that contains connected data.

- Cell: the intersection of rows and columns where data is kept.

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

cannot be null or duplicated.

 Relationship

Foreign Key: is a field in this table that has a corresponding field as a


primary key in another table in order to establish a relationship between
the two tables.

Relationship: Creates a relationship between two tables in order to


determine the relationship between their data fields.

 Forms of relationships

- One-to-one relationship: each table contains exactly one record. For


example, a husband-wife connection, a link between basic and complex
knowledge...

- 1-n relationship: The most prevalent relation in the database is the 1-


n relation. In this method, one table in one table corresponds to several
entries in another table.

- n-n relationship: One record in one table correlates to numerous


records in the other, and vice versa.

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

- Aids in better understanding of the database layer

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.

 Attribute: A trait that contains a value for an entity or relation type.

 Entity relationships

- One-to-one connection: exists when an entity from entity set X is


related with an entity from entity set Y, and vice versa.

- One-to-many connection: exists when an entity from entity set X is


associated with many entities from entity set Y, but an entity from entity
set Y is only related with one entity from entity set X.

- Many-to-many relationship: An entity in set X can be linked to many


entities in set Y, and an entity in set Y may be linked to many entities
in set X.

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

- Works with all browsers and on multiple platforms

- Built-in components of ERD and many different diagrams

- Offers multiple choices of place to save your work

- Unlimited size – you can draw as much as you want

- Generates database diagrams in many formats, including uml (Unified


Modeling Language), erd, and others.

 Paint

- Easy to use

- You can draw anything

CONS:

- Does not have built-in components to build a diagram

- Hard to make a good-looking diagram

→ draw.io has too many advantages over Paint: it has all


the elements you need, it’s optimized for creating a
diagram, and, moreover, it doesn’t require downloading;
so I am using draw.io.

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.

Based on users’ interaction with database systems, there are different


styles of 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.

A relational model would be the most suitable database schema for


OOP programs, as it store each object’s data in its own table in the
database.

 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

This sort of design is beneficial in circumstances where information


must be added and deleted fast. It is commonly used in
telecommunications, healthcare, and finance. The information at the top
of the hierarchy is easily accessible.

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)

b. Purposes of database schemas


- Identifies different tables and fields of each table.

- Describes the relationships between different tables.

- Identifies the constraints on the system.

- It is a structure described in a formal language supported by the


DBMS.

- Defines the tables, fields, relationships, views, indexes etc.

19
c. Convert ERD into relational schema
Step 1: Create an appropriate relation type for each entity type

- Turning 1-1 links brings 2 entities into one entity

- 1-N associations take the side key of multiple entities and convert it
to a foreign key

- State relationships form a new type of relationship

Step 2: Check the relationship's typical structure

5. Relational Database Management System


(RDBMS)

a. Definition and uses


“The software used to store, manage, query, and retrieve data stored in
a relational database is called a relational database management system
(RDBMS). The RDBMS provides an interface between users and
applications and the database, as well as administrative functions for
managing data storage, access, and performance.” (What is a Relational
Database (RDBMS)?)

b. Different RDBMS(s)
The number of RDBMS is enormous, but here are some of the most
widely used ones.

 MySQL

MySQL is an open-source RDBMS. Its name is a combination of "My",


the name of co-founder Michael Widenius's daughter My, and "SQL",
the abbreviation for Structured Query Language. It is written in C/C++
and developed by Oracle Corp. It is compatible with Linux, Solaris,
macOS, Windows, FreeBSD and used by many popular database-
driven web apps such as Drupal, Joomla, WordPress, etc. It is also used
by various websites like Facebook, Twitter, YouTube, etc.

* Features

- High performance

- High availability

- Scalable and flexible

20
- Strong support for transactions - a unit of processing in SQL,
consisting of a group of statements for sequential processing of
database operations

- Strong web and data warehouse

- Powerful data protection

- Easy management

- Reasonable cost

 Microsoft SQL Server

Microsoft SQL Server is a relational database management system that


Microsoft created. It is a database server, which is a software product
that stores and retrieves data as required by other software programs,
which may operate on the same or on a different computer over a
network (including the Internet). Just like MySQL, it is written in
C/C++ and used widely all around the world.

* Features

- Reasonable price and performance, better when used at a large scale

- High performance data warehouse

- Safe and well compatible

- High availability and recoverability

- Enterprise-level intelligent collaboration

- Perfect integration across multiple devices

- Simplify small and medium data

- Advanced data analysis tools

- Real-time advanced analysis and processing

- Unified data platform across platforms

- Easy-to-use tools and connectors

 Oracle Database

Oracle Database is a relational database management system produced


by Oracle Corporation. It “is the first database designed for enterprise
grid computing, the most flexible and cost-effective way to manage
information and applications.” (Oracle)
21
Oracle supports all major operating systems, on both clients and
servers, including MS DOS, NetWare, UnixWare, OS/2 and most
UNIX versions.

* Features

- Simultaneous access: Supports for multiple users accessing the same


data unit at the same time

- Consistency

- Portability

- Self-managed database

- Resource management

- Data Mining

- Partitions

- Bitmap index

- Supports large-volume data management

- Ability to work 24/7

- Safe mechanism, good security

- Ensure data integrity binding from simple to complex on the database

For my assignment, I have decided to use MS SQL Server, since it is


very easy to install with its one-click installation procedure and user-
friendly installation interface. Besides, it is considered to be one of the
most secure database servers. Unlike other RDBMS(s), it is not an
open-source database server, which will reduce the threat of being
attacked. With complex encryption algorithms, MS SQL Server is
virtually impossible to crack the security layers enforced by the user.
Moreover, since my device is seldom unstable, I choose MS SQL for
its excellent data restoration and recovery mechanism.

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:

 First Normal Form (1 NF)

- Each table cell should contain a single value

- Each record must be unique

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

 Second Normal Form (2 NF)

- 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

CUSTOMERS’ ID PHONE NUMBER


1 0946178346
1 0357312649
2 0956588463
2 0943648235
3 0346584718
Table 2

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.

We have introduced a new column called CUSTOMERS’ ID which is


the primary key for table 1. Records can be uniquely identified in Table
1 CUSTOMERS’ ID

 Third Normal Form (3 NF)

- 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

CUSTOMERS’ ID PHONE NUMBER


1 0946178346
1 0357312649
2 0956588463
2 0943648235
3 0346584718
Table 2
GENDER ID GENDER
1 Male
2 Female
Table 3

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

 Boyce Codd Normal Form or Fourth Normal Form (BCNF or 4


NF)

Even when a database is in 3rd Normal Form, still there would be


anomalies resulted if it has more than one Candidate Key.

Sometimes is BCNF is also referred as 3.5 Normal Form.

If no database table instance contains two or more, independent and


multivalued data describing the relevant entity, then it is in 4th Normal
Form.

 Fifth Normal Form (5 NF)

A table is in 5th Normal Form only if it is in 4NF and it cannot be


decomposed into any number of smaller tables without loss of data.

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

The CREATE DATABASE statement is used to create a new SQL

database.

 The SQL DROP DATABASE Statement

The DROP DATABASE statement is used to drop an existing SQL


database.

 The SQL BACKUP DATABASE Statement

The BACKUP DATABASE statement is used in SQL Server to create


a full back up of an existing SQL database.

 The SQL CREATE TABLE Statement

The CREATE TABLE statement is used to create a new table in a


database.

 The SQL DROP TABLE Statement

25
The DROP TABLE statement is used to drop an existing table in a
database.

 SQL ALTER TABLE Statement

The ALTER TABLE statement is used to add, delete, or modify


columns in an existing table.

The ALTER TABLE statement is also used to add and drop various
constraints on an existing table.

 The SQL SELECT Statement

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 SQL SELECT DISTINCT Statement

The SELECT DISTINCT statement is used to return only distinct


(different) values.

Inside a table, a column often contains many duplicate values; and


sometimes you only want to list the different (distinct) values.

 The SQL WHERE Clause

The WHERE clause is used to filter records.

It is used to extract only those records that fulfill a specified condition.

 The SQL AND, OR and NOT Operators

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:

The AND operator displays a record if all the conditions separated by


AND are TRUE.

The OR operator displays a record if any of the conditions separated by


OR is TRUE.

The NOT operator displays a record if the condition(s) is NOT TRUE.

The SQL INSERT INTO Statement

The INSERT INTO statement is used to insert new records in a table.

It is possible to write the INSERT INTO statement in two ways:

1. Specify both the column names and the values to be inserted:

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:

 The SQL UPDATE Statement

The UPDATE statement is used to modify the existing records in a


table.

 The SQL DELETE Statement

27
The DELETE statement is used to delete existing records in a table.

 SQL Aliases

SQL aliases are used to give a table, or a column in a table, a temporary


name.

Aliases are often used to make column names more readable.

An alias only exists for the duration of that query.

An alias is created with the AS keyword.

or to give a table a temporary name:

 SQL JOIN

A JOIN clause is used to combine rows from two or more tables, based
on a related column between them.

- SQL INNER JOIN Keyword

The INNER JOIN keyword selects records that have matching values
in both tables.

- SQL LEFT JOIN Keyword

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.

- SQL RIGHT JOIN Keyword

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.

- SQL FULL OUTER JOIN Keyword

The FULL OUTER JOIN keyword returns all records when there is a
match in left (table1) or right (table2) table records.

- SQL Self Join

A self join is a regular join, but the table is joined with itself.

T1 and T2 are different table aliases for the same table.

(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.

- Confirm that the software system satisfies the customer's functional,


technical, and business needs.

29
- Testing a software product from to the end helps avoid system errors
and issues when installation in a real setting.

- Performed in a setting approximating production, giving stakeholders


and developers a sense of how users will respond to the product.

- Be essential in getting a high-quality product to the customer.

- Verify that the input produces the desired outcome

30
References
(n.d.). Retrieved from Oracle:
https://docs.oracle.com/cd/B19306_01/server.102/b14220/intro.htm

(n.d.). Retrieved from W3Schools:


https://www.w3schools.com/sql/default.asp

Types of Databases. (n.d.). Retrieved from javaTpoint:


https://www.javatpoint.com/types-of-databases

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

What is a Relational Database (RDBMS)? (n.d.). Retrieved from


Oracle: https://www.oracle.com/database/what-is-a-relational-
database

What is a relational database? (n.d.). Retrieved from Google Cloud:


https://cloud.google.com/learn/what-is-a-relational-database

31
III. Practice

1. Analyze the problem


Build a software which helps managing and selling phone products for
their retail chain.

- Customers will know basic information about the products: IMEI,


Name, Manufacturer, Release date, RAM, ROM, Chip, Phone size,
Price.

- Phones will be stored at warehouses.

- One customer can order many phones.

→ 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

-There are staffs in charge of executing orders

- 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

- Staffs: ID, Name, Phone number

- Stores: ID, Name, Address, Phone number

32
- Warehouses: ID, Categories, Quantity

- Phones: ID, IMEI, Name, Manufacturer, Release date, RAM, ROM,


Chip, Phones’ size (length, width, height), screen size, Price

- Shipping: ID, Name, Phone number

- Orders: ID, order date, Total price

4. Relationships of entities
- One customer has many orders

- One phone belongs to only one order

- One warehouse can have many phones or no phone

- Many staffs may manage a warehouse

- Many staffs manage a store

- One staff can handle many orders

- One shipper can ship 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

2. Set strong password

3. Set 2-layers authentication

4. Use a network security risk management solution

IV. Test log and test case

39
1. Test log

Solution: DROP, and try again, it should work

2. Test case

Solution: change variable int to VARCHAR

40

You might also like