database
database
9.1 Introduction
This unit specifies competencies required to manage database system. They include
identification of database management systems, designing of database, Creation and
manipulation of database, database testing e.g. using dummy data, implementation of the
designed database, establishing transaction and concurrency mechanism and managing
database security
These are the key learning outcomes, which make up workplace function:
o Identify database management system
o Design database
o Create and manipulate database
o Perform database testing
o Implement designed database
o Establish transaction and concurrency mechanism
o Manage database security
181
9.3.2 Learning Outcome 1: Identify database management system
itself, the data format, field names, record structure and file structure. It also defines rules to
t.c
validate and manipulate this data. A DBMS relieves users of framing programs for data
ve
yt
maintenance. Fourth-generation query languages, such as SQL, are used along with the
s
ea
Some other DBMS examples include: MySQL, SQL Server, Oracle, dBASE, FoxPro
Classification based on Data Model: The most popular data model in use today is the
relational data model. Well-known DBMSs like Oracle, MS SQL Server, DB2 and MySQL
support this model.
• Centralized database system: the DBMS and database are stored at a single site that is
used by several other systems.
• Distributed database system: the actual database and the DBMS software are distributed
from various sites that are connected by a computer network
• Heterogeneous distributed database system: different sites might use different DBMS
software, but there is additional common software to support data exchange between
these sites
• Homogeneous distributed database systems: use the same DBMS software at multiple
sites
• Multiuser database system: a database management system, which supports multiple
users concurrently
• Object-oriented data model: a database management system in which information is
182
represented in the form of objects as used in object-oriented programming
• Single-user database system: a database management system which supports one user at
a time
• Traditional models: data models that preceded the relational model
9.3.2.3 Self-Assessment
i. What is database management?
ii. Explain database classification?
iii. What is the difference between centralized and distributed database systems?
iv. What is the difference between homogenous distributed database systems and
heterogeneous distributed database systems?
v. Provide three examples of the most popular relational databases used.
vi. DBMS is software.
A. True
B. False
vii. DBMS manages the interaction between __________ and database.
A. Users
om
B. Clients
t.c
ve
C. End Users
yt
D. Stake Holders
s
ea
9.3.2.5 References
• https://www.techopedia.com/definition/24361/database-management-systems-dbms
• https://opentextbc.ca/dbdesign01/chapter/chapter-6-classification-of-database-systems/
183
• Database Systems: Design, Implementation, & Management 12th Edition authored by
Steven Morris, Carlos Coronel, published by Cengage Learning; 12 edition 2016
Instance: The data stored in database at a particular moment of time is called instance of
database. Database schema defines the variable declarations in tables that belong to a
particular database; the value of these variables at a moment of time is called the instance of
that database.
184
A database operation is the vehicle through which users and applications have access
to data in relational databases. Each database operation accesses one relational database.
om
t.c
ve
syt
ea
Source: https://slideplayer.com
Figure 74: User database operations
185
Watch: MySQL queries: https://youtu.be/XMY6Wt1NREg
om
t.c
ve
yt
s
ea
Source: https://www.guru99.com
Figure 75: Data Model
186
An entity–relationship model (or ER model) describes interrelated things of interest in a
specific domain of knowledge. A basic ER model is composed of entity types (which
classify the things of interest) and specifies relationships that can exist between entities
(instances of those entity types).
om
t.c
ve
yt
s
ea
Source: http://jcsites.juniata.edu
Figure 76: Entity-relationship model
187
In the relational model, all data must be stored in relations (tables), and each relation
consists of rows and columns.
om
t.c
ve
yt
s
ea
Source: https://en.wikipedia.org
Figure 77: Relation model
188
Hierarchical Models (aka Hierarchical Linear Modelsor HLM) are a type of linear
regression models in which the observations fall into hierarchical, or completely nested
levels. Hierarchical Models are a type of Multilevel Models.
Classification 1
2nd level
classification 1
Classification 2
Classification 1
t.c
2nd level
ve
classification 3
yt
s
Classification 2
ea
189
A network model is a database model that is designed as a flexible approach to representing
objects and their relationships. A unique feature of the network model is its schema, which is
viewed as a graph where relationship types are arcs and object types are nodes.
om
Source: http://www.dbmsinternals.com
t.c
9.3.3.3 Self-Assessment
i. Write a SQL query to fetch all records FROM table?
ii. Write a SQL query to create a new table with data and structure copied from another
table?
iii. Who proposed the relational model?
vi. Define database model.
v. What is the purpose of SQL?
vi. What is DBMS used for?
vii. What is E-R model in the DBMS?
viii. Which SQL function is used to count the number of rows in a SQL query ?
A. COUNT()
B. NUMBER()
C. SUM()
D. COUNT(*)
ix. What mode of authentication does SQL Server NOT provide?
A. Windows-only security
B. Both SQL Server and Windows-only security
C. Mixed security
D. SQL Server only security
x. If you don’t specify ASC or DESC after a SQL ORDER BY clause, the following is
used by default
190
A. ASC
B. DESC
C. There is no default value
D. None of the mentioned
xi. Which of the following statement is true?
A. DELETE does not free the space containing the table and TRUNCATE free the
space containing the table
B. Both DELETE and TRUNCATE free the space containing the table
C. Both DELETE and TRUNCATE does not free the space containing the table
D. DELETE free the space containing the table and TRUNCATE does not free the
space containing the table
9.3.3.5 References
• https://www.w3schools.com/sql/default.asp
• https://www.softwaretestinghelp.com/database-design-tools/
• Database Systems: Design, Implementation, & Management 12th Edition authored by
Steven Morris, Carlos Coronel, published by Cengage Learning; 12 edition 2016
om
191
One is selected as the primary key. Those not selected are known as secondary keys. For
example, an employee has an employee number, a National Insurance (NI) number and an
email address. If the employee number is chosen as the primary key then the NI number and
email address are secondary keys.
om
t.c
ve
Source: https://www.researchgate.net
yt
s
Linking of table is a very common requirement in SQL. Different types of data can be stored
in different tables and based on the requirement the tables can be linked to each other and the
records can be displayed in a very interactive way.
Source: https://www.plus2net.com
Figure 81: Table linkages
192
of birth, capital expenditure, class grades, eye colour and vehicle type are examples
of variables.
An integration database is a database, which acts as the data store for multiple applications,
and thus integrates data across these applications (in contrast to an Application Database).
An integration database needs a schema that takes all its client applications into account.
om
t.c
ve
syt
ea
Source: https://en.wikipedia.org/wiki/Data_integration
Figure 82: Integration of database
SQL is a domain-specific language used in programming and designed for managing data
held in a relational database management system, or for stream processing in a relational data
stream management system.
9.3.4.3 Self-Assessment
i. How to create table?
ii. What is table linkage?
iii. Define data variable?
iv. What the difference between primary key and secondary key?
v. What is SQL?
vi. A medical Centre wishes to computerize all its patients’ records
a) Create database for the Centre and save it as your name and personal number.
193
b) InDesign View, Create a table with the following properties and save it as patient
Bio Table.
Field Name Properties
Patient Name Text (20)
Sex Text (1)
Residence Text (20)
Patient code Text (4)
Date of visit Date/Time(short date)
Diagnosis Text (25)
c) Create a form for patient Bio table and enter the records below, save it as patient
bio form
Patient Name Sex Residence Patient Date of Diagnosis
Code visit
Victor sam M Kangemi ADS011 3/8/2018 Septic
Wound
Stella mugo F Kisumu ADS025 9/1/2019 Malaria
Mwangi Nema F Buru buru ADS014 23/4/2018 Inflamed
joints
Njambi ella F Bulenga ADS034 14/2/2019 Infections
om
in chest
t.c
ve
d) InDesign view, create another table with the following properties and save it as
patient billing Table.
Field Name Properties
Patient Code Text (4), Primary Key
Prescription Memo
Consult_fee Number
Treat_fee Number
Medical bill Number
Medical is a calculated field which is Consult_fee+ Treat_fee
194
f) Create a one-to-one relationship between the Patient Bio Table and the Patient
Billing Table.
g) Create a query which extract from patient bio table only those patients who were
not diagnosed with malaria. Save it as anti-malaria.
h) i.) Create a report showing Name, Residence, Prescription and Medical Bill. Save
it as clinic report.
ii.) Include a report footer of your name and personal number.
iii.) Print all your work.
vii. A logical schema is -
A. Is the entire database
B. Describe data in terms of relational tables and columns, object-oriented classes,
and XML tags
C. Describes how data is actually stored on disk.
D. Both (A) and (C)
vii. The database environment has all of the following components except:
A. Users.
B. Separate files
C. Database.
D. Database administrator
viii. The way a particular application views the data from the database that the application
om
uses is a
t.c
A. Module.
ve
yt
B. Relational model.
s
ea
C. Schema.
D. Sub schema.
ix. Which is the subset of SQL commands to manipulate Oracle Database structures,
including tables,
A. Data Definition Language (DDL)
B. Data Manipulation Language (DML)
C. Both of above
D. None
9.3.4.5 References
• https://www.guru99.com/how-to-create-a-database.html
• https://www.plus2net.com/sql_tutorial/sql_linking_table.php
• https://www.coursera.org/lecture/core-database/part-1-sql-query-language-vevDZ
• Database Systems: Design, Implementation, & Management 12th Edition authored by
Steven Morris, Carlos Coronel, published by Cengage Learning; 12 edition 2016
• SQL QuickStart Guide: The Simplified Beginner's Guide To SQL authored by
ClydeBank Technology published by CreateSpace Independent Publishing Platform 2015
195
9.3.5 Learning Outcome 4: Perform database testing
Integration testing is a level of software testing where individual units are combined
and tested as a group. The purpose of this level of testing is to expose faults in the interaction
between integrated units. Test drivers and tests tubs are used to assist in Integration Testing.
om
t.c
Database Testing is checking the schema, tables, triggers, etc. of the database under test. It
ve
yt
may involve creating complex queries to load/stress test the database and check its
s
ea
Database Schema Testing: As mentioned earlier, it involves testing each object in the
Schema.
196
o Stored Procedure Parameters: Call stored procedure with boundary data and with valid
data. Make each parameter invalid once and run a procedure.
o Return values: Check the values that are returned by stored procedure. In case of a failure,
nonzero must be returned.
o Error messages check: Make changes in such a way that the stored procedure fails and
generate every error message at least once. Check any exception scenarios when there is
no predefined error message.
Stress Testing involves getting a list of major database functions and corresponding stored
procedures. Follow the steps given below for Stress Testing:
om
o Write test scripts to try those functions and every function must be checked at least once
t.c
in a full cycle.
ve
yt
o Perform the test scripts again and again for a specific time period.
s
ea
o Verifying the log files to check any deadlocks, failure out of memory, data corruption,
etc.
Benchmark Testing
If your database does not have any data problems or bugs, system performance can be
checked. A poor system performance can be found in benchmark testing by checking the
parameters given below:
o System level performance
o Identify most-likely-used functions/features
o Timing – maximum time, minimum time and average time to perform functions
o Access volume
197
9.3.5.3 Self-Assessment
i. What is database testing?
ii. Differentiate trigger testing and stress testing?
iii. When you are testing database, what do you need to check normally as an IT
technician?
iv. How would you know for database testing, whether trigger is fired or not?
v. While testing stored procedures what are the steps does a tester takes?
vi. _________ involves getting a list of major database functions and corresponding
stored procedures.
A. Benchmark Testing
B. Stress Testing
C. Trigger test
D. None
vii. Trigger testing which tasks tester must perform?
A. Make sure the trigger name is correct.
B. Validate the trigger if it is generated for a specific table column.
C. Trigger’s update validation.
D. Update a record with a valid data.
E. Both of above
F. None of above
om
A. Database Testing
ve
yt
C. Benchmark Testing
D. None of above
9.3.5.5 References
• https://www.guru99.com/data-testing.html
• https://www.tutorialspoint.com/database_testing/database_testing_techniques.htm
• Database Systems: Design, Implementation, & Management 12th Edition authored by
Steven Morris, Carlos Coronel, published by Cengage Learning; 12 edition 2016
198
9.3.6 Learning Outcome 5: Implement designed database
199
Database Testing is checking the schema, tables, triggers, etc. of the database under test. It
may involve creating complex queries to load/stress test the database and check its
responsiveness. It checks data integrity and consistency.
Non-
Structural Functional Functional
Testing Testing
Testing
Source: www.guru99.com
Figure 83: Types of database testing
9.3.6.3 Self-Assessment
i. What is database testing?
ii. Explain design process of database?
iii. ________ choose each table’s primary key. The primary key is a column that is used
to uniquely identify each row. An example might be Product ID or Order ID.
A. Refine your design
om
D. None of Above
s
ea
E. Both of above
iv. Analyze your design for errors. Create the tables and add a few records of sample
data. See if you can get the results you want from your tables. Make adjustments to
the design, as needed.
A. Refine your design
B. The design process
C. None of above
D. Both A and B
E. Apply the normalization rules
v. An enterprise data model is a relational model that shows the high-level entities for
the organization and associations among those entities.
A. True
B. False
vi. Term that is considered as a basis for most robust authentication schemes, is said to
be
A. Identification
B. Registration
C. Encryption
D. Refine information
200
9.3.6.4 Tools, Equipment, Supplies and Materials
Computer, Data Factory, MockupData, SQL Server
9.3.6.5 References
• https://support.office.com/en-us/article/database-design-basics-eb2159cf-1e30-401a-
8084-bd4f9c9ca1f5
• https://www.guru99.com/data-testing.html
• Database Systems: Design, Implementation, & Management 12th Edition authored by
Steven Morris, Carlos Coronel, published by Cengage Learning; 2016
Due to the nature of SQL and relational database architecture, where each update can act on
only one table at a time and where there are no trailers in the usual sense, two update
statements must be executed simultaneously. Both update statements must either succeed and
COMMIT or fail and ROLLBACK.
201
om
t.c
ve
yt
s
Source: www.guru99.com
ea
Source: Tutorials4us.com
Figure 85: Transaction management
202
9.3.7.3 Self-Assessment
i. What is transaction mechanism?
ii. Differentiate between transaction mechanism and concurrency mechanism?
iii. What is managing multiple transactions?
iv. Any non-serial interleaving of T1 and T2 for concurrent execution leads to
A. A serializable schedule
B. A schedule that is not conflict serializable
C. A conflict serializable schedule
D. A schedule for which a precedence graph cannot be drawn
v. Which of the following locks the item from change but not from read?
A. Implicit lock
B. Explicit lock
C. Exclusive lock
D. Shared lock
vi. A transaction in which either all of the database actions occur or none of them do is
called:
A. Atomic
B. Consistent
C. Isolated
D. Durable
om
vii. Which of the following occurs when one transaction reads a changed record that has
t.c
A. No repeatable read
s
ea
B. Phantom read
C. Dirty read
D. Consistent read
9.3.7.5 References
• http://ftp.magicsoftware.com/www/help/uniPaaS/mergedprojects/MGHELPW/Data_Man
agement/SQL_Considerations/Transaction_Mechanism.htm
• Database Systems: Design, Implementation, & Management 12th Edition authored by
Steven Morris, Carlos Coronel, published by Cengage Learning; 2016
203
9.3.8 Learning Outcome 7: Manage database security
o Physical security of the database server and backup equipment from theft and natural
ve
yt
disasters
s
ea
o Reviewing existing system for any known or unknown vulnerabilities and defining and
implementing a road map/plan to mitigate them
204
So a file that is updated after a normal backup will be archived every time a differential
backup is run until the next normal backup runs and clears the archive bit.
Design methodology: A structured approach that uses procedures, techniques, tools, and
documentation aids to support and facilitate the process of design. A design methodology
consists of phases each containing a number of steps, which guide the designer in the
techniques appropriate at each stage of the project.
Conceptual database design: The process of constructing a model of the information used
in an enterprise, independent of all physical considerations. The conceptual database design
phase begins with the creation of a conceptual data model of the enterprise, which is entirely
independent of implementation details such as the target DBMS, application programs,
programming languages, hardware platform, performance issues, or any other physical
considerations.
205
Physical database design
It is a description of the implementation of the database on secondary storage; it describes the
base relations, file organizations, and indexes used to achieve efficient access to the data, and
any associated integrity constraints and security measures.
Whereas logical database design is concerned with the what, physical database design is
concerned with the how. The physical database design phase allows the designer to make
decisions on how the database is to be implemented. Therefore, physical design is tailored to
a specific DBMS. There is feedback between physical and logical design, because decisions
taken during physical design for improving performance may affect the logical data model.
For example, decisions taken during physical for improving performance, such as merging
relations together, might affect the structure of the logical data model, which will have an
associated effect on the application design.
selection of file organizations, selection of indexes and estimates the disk space requirements.
ve
yt
determine the optimal file organizations to store the base relations and the indexes· that are
required to achieve acceptable performance, that is, the way in which relations and tuples will
be held on secondary storage.
One of the main objectives of physical database design is to store data in an efficient ay.
There are a number of factors that we may use to measure efficiency:
• Transaction throughput
This is the number of transactions that can be processed in a given time interval.
In some systems, such as airline reservations, high transaction throughput is critical to the
overall success of the system.
• Disk storage
This is the amount of disk space required to store the database files. The designer may wish
to minimize the amount of disk storage used.
9.3.8.3 Self-Assessment
i. What are types of backup?
ii. What is database security?
A. Data encryption
B. A view
C. Fingerprint
D. All of the above
206
iii. Data security threats include
A. Privacy invasion
B. Hardware protection
C. Fraudulent manipulation od data
D. All of the above
iv. _______ is responsible for using that the database remains in a consistent state despite
system failure.
A. Storage Manager
B. Transaction manager
C. End user
D. Sophisticated
v. Prevention of access to the database by unauthorized users is referred to as:
A. Integrity
B. Productivity
C. Security
D. Reliability
vi. How will you know your database is unsecure and which software will you use to
make it secure
9.3.8.5 References
s
ea
• https://www.solarwindsmsp.com/content/types-of-database-backups
• Database Systems: Design, Implementation, & Management 12th Edition authored by
Steven Morris, Carlos Coronel, published by Cengage Learning; 2016
207