DATABASE MANAGEMENT SYSTEM
By
Lecturer: Okello Emmanuel
Tel: +256 784990516
Email: [email protected]
Introduction
The database is now such an integral part of our
day-to-day life that often we are not aware we are
using one.
Introduction
A database is a collection of related data
Database Management System (DBMS) is a software that
manages and controls access to the database.
A database application is a program that interacts with the
database at some point in its execution.
A database system is a collection of application programs that
interact with the database along with the DBMS and database
itself.
The basic idea of a database is to store data in an organized way.
Examples of Database Applications
(Uses)
Supermarkets
ATM cards
Library systems
University student record management system
Airline reservation systems
Traditional File Systems
In computing, a file-system is a method for storing and
organizing computer files and the data they contain to
make it easy to find and access them.
File-systems were an early attempt to computerize the
manual filing system; the normal filing system works
well while the data items to be stored are few. However,
it becomes impossible to use when we have to cross-
reference or process data in the file.
Example – File Based University
System
Hall – Student No, Name, DOB, District, Year of Reg, Course
Faculty – Student No, Name, DOB, Course, Results, Fees
payable, Fees paid
Registrar – Student No, Name, DOB, District, Year of Reg,
Faculty, Course, Results, Sponsor
Library - Student No, Name, Faculty, Course, Borrowed
book, Date of return
Bursar - Student No, Name, Faculty, Course, Fees payable,
Fees paid, Sponsor
Problems
Each department accesses its own data through
application programs specifically written for that
department
Un-necessary duplication of data – ( Time, Space,
Personnel costs increase)
Cross-referencing can not be efficiently done
Limitations of the File-Based Approach
Separation and isolation of data
When data is isolated in separate files, it is
more difficult to access data that should be
available.
Duplication of data
Same data is held by different programs.
It takes up additional storage space, again
with associated costs.
May lead to loss of data integrity
Limitations of the File-Based Approach……
Incompatible file formats
Programs are written in different languages,
and so cannot easily access each others files.
Structure of a file generated by a COBOL program
may be different from that of Fotran, C++ etc
Limitations of the File-Based Approach……
Fixed Queries of application programs
Query / Reports were fixed. No facility for ad
hoc reports. Often these functionalities were
omitted:
• Integrity and security features
• Recovery mechanisms in the event of
hardware or software failures
• Multi-user functionality
Database Approach
Database
A shared collection of logically related data, and a
description of this data, designed to meet the
information needs of an organization.
Database Approach……
The term ‘logically related’ means that; When we
analyze the information needs of an organization,
we attempt to identify entities, attributes, and
relationships.
Note:
The total numbers of entities and relationships
depend on the nature of the organization and the
required data to be stored.
Database Approach……
An entity is a distinct object (e.g. a person, a place
etc) in the organization that is to be represented in
the database.
An Attribute is a property that describes some
aspect of the object that we wish to record (e.g.
name, height, and sex of a person)
Database Approach….
A relationship is an association between
entities.
The database represents the entities, the
attributes, and the logical relationships between
the entities. In other words, the database holds
data that is logically related.
Entities and their attributes
Taking KUMU as our case study, we can create a
database by identifying the following
Entity1: student
Attributes: student’s regNo, student’s name, age,
homeaddress, etc
Entity2: lecturer
Attributes: lecturer IDNo, name, age, status, etc
Entities and their attributes….
Entity3: course
Attributes: course IDNo, course Name,
lectureIDNo
Entity4: lecture_room
Attributes: room No, room Name, location
Relation Ship1: course lectured by lecturer
Relation Ship2: course taken by student
Components of a Database
A database comprises of various
components/objects that include the following;
Tables:- A table is a primary object of the
database. Tables are used to collect and store data
relating to a particular subject.
Table Name: Registration
(an example of a table structure)
Tables are organized in rows and columns as shown in
the figure below:
studentNo fisrtName lastName age sex
2006/REC/026 Mukasa John 32 M
2006/ITB/013 Namukasa Mary 28 F
Table description
Each column is called a Field or an attribute and it
contains the same type of information for every entity
occurrence.
Each row is called a record or a tuple and it contains
all the information about one entity occurrence.
Forms
A form allows a user to view one record at a time on
the screen.
It is also commonly used to send information into a
table.
Normally, each table has a corresponding form for
entering data in it. Figure on the next slide shows a
form for entering data in the above table.
A Form for entering or viewing data in
a table
Queries
A query is a question you ask the database. In a
database that stores student’s data, you might
query/ask the database for a list of all students who
are over the age of 30. The answer usually is a list of
records matching the query condition(s).
Data can also be drawn from more than one table
and displayed in a single query that can later be used
to produce reports.
Reports
They are used to present, summarize and print table
data. Using reports, we can calculate totals and
subtotals across a set of records.
Reports can be printed out to present data and
information on a hard copy.
Advantages of using databases
Removes duplication of records
Ensures integrity of data, that is, validity and
consistency of data. This is achieved by implementing
rules that the database is not permitted to violet
Creates uniformity of records
Ensures security of data by restricting unauthorized
access
Advantages of using databases cont’d.
Convenience in retrieval and analysis of data
Availability of up-to-date information
Allows multiple usage
Improved backup and recovery services
Disadvantages of using databases
In spite of these advantages, there are some situations
where using a DBMS may incur unnecessary overhead
costs as compared to traditional file processing. They
include;
High initial investment in hardware, software and
training.
Not fully reliable e.g. in a networked environment, the
entire organization comes to a stand still if the server
crashes.
Disadvantages of using databases
cont’d.
• Requires a lot of time to design. This is because the functionality we
expect of a good database makes the DBMS an extremely complex
piece of software to design.
• Performance: typically, a file-based system is written for a specific
application, such as invoicing, payroll, etc. As a result, performance
is generally very good. However, the DBMS is written to be more
general to cater for many applications rather than just one. The
result is that some applications may not run as fast as before.
Database Systems Vs File Systems
File Systems
There are a number of characteristics that databases differ
from traditional file management system. In file system
approach, each user defines and implements the needed
files for a specific application. For example in an institution
like KUMU, the office of the academic registrar will
maintain records of how many registered students have
joined the institution. These details will be stored and
maintained in a separate file.
Database Systems Vs File Systems
File Systems cont…..
Another user in the bursar’s office will be maintaining
tuition details of all students. The detailed tuition report
will be stored and maintained in a separate file. Although
both of the users are interested in the data items of the
same students, they will be having their details in
separate files and they need different programs to
manipulate their files. This will lead to the following:
Database Systems Vs File Systems
DEMERITS OF File-Systems
wastage of storage space
redundancy or replication of data items, which may
lead to confusion,
sharing of data among various users is not possible,
also data inconsistency may occur.
Database Systems Vs File Systems
DEMERITS OF File-Systems
There will not be any inter-relationship among the
data’s stored in these files. Therefore in traditional file
processing every user will be defining their own
constraints/rules and implement the files needed for
the applications.
Database Systems Vs File Systems
Database Systems
In database approach, a single repository of data is
maintained that is defined once and then accessed by
many users.
The fundamental characteristic of database approach is
that the database system not only contains data items
but it contains complete definition or description of the
database structure and constraints/rules.
Database Systems Vs File Systems
Database Systems cont…
The other main characteristic of the database is that it
will allow multiple users to access the database at the
same time and sharing of data is possible. The
database must include concurrency control software to
ensure that several users can update the same data at
the same time, but this should be maintained in a
controlled manner.
In summary, Databases are important
because….
1. They can store a large number of records,
2. There is ease of use when accessing information,
3. It is easy to add new data and to edit or delete old
data,
4. There is ease of storage,
5. More than one person can access the same database
at the same time, and
6. Data security is enhanced as access to some of the
information is restricted.
The Database Management System
DBMS is a software system that enables users to
define, create, maintain, and control access to the
database.
The DBMS is the software that interacts with the users’
application programs and the database.
In fact, most of today's database systems are referred to as a
Relational Database Management System (RDBMS), because
of their ability to store related data across multiple tables.
The Database Management System……
Typically, a DBMS provides the following facilities:
It allows users to define the database, usually
through a Data Definition Language (DDL).
The DDL allows users to specify the data types
and structures and the constraints on the data
to be stored in the database.
The Database Management System……
It allows users to insert, update, delete, and
retrieve data from the database, usually through a
Data Manipulation Language (DML).
The Database Management System……
It provides controlled access to the database. For
example, it may provide:
i. a security system, which prevents unauthorized
users accessing the database;
ii. an integrity system, which maintains the
consistency of stored data;
iii. a concurrency control system, which allows shared
access of the database;
iv. a recovery control system, which restores the
database to a previous consistent state following a
hardware or software failure;
v. a user-accessible catalog, which contains
Examples of Relational database
management systems
Some of the more popular relational database
management systems include:
1. Microsoft Access
2. MySQL
3. Oracle
4. Sql Server
5. PostgreSql
Components of a DBMS environment
Components of a DBMS are identified as;
1. Hardware,
2. Software,
3. Data,
4. Procedures, and
5. People.
ILLUSTRATION OF THE COMPONENTS
OF A DBMS ENVIRONMENT
Components of a DBMS
• Hardware: The database requires computer hardware
to run. The hardware can range from a single Personal
Computer to a network of computers. The hardware
depends on the organization’s information
requirements and the DBMS used.
• Software: The software component comprises of the
DBMS itself, together with the operating system,
including network software if the DBMS is to be used
on a network.
• Data: From the end user’s point of view, data is the
most important component of a DBMS environment
(metadata). The database contains both the operational
data and the metadata, the ‘data about data’.
Components of a DBMS
Procedures: These are instructions and rules that
govern the design and use of the database. Database
users require documented procedures on how to use
and run the database system. Such procedures may
consist of instructions on how to:
1. - log on the DBMS
2. - start/stop the DBMS
3. - make backup copies of the database etc
Components of a DBMS
People: We can identify four distinct types of people
that participate in the DBMS environment:
1. Data and Database Administrators
2. Database Designers
3. Application Developers
4. End-Users; Naïve users, Sophisticated users
Components (cont’d)
Users of the database communicate their
requirements to the database using Data Definition
Language (DDL) and Data Manipulation Languages
(DML).
Generally, the DBMS provides an interface between
the user’s programs and the contents of the database.
DBMS Interfaces
When you are using a basic command-line DBMS such
as Oracle, and MySql, external development are
required to build application programs which can be
used to access the database. E.g. u can use Visual Basic
to create the application, and use the database for
storage.
However, there are graphical DBMS such as Access
which has a built-in application for building its own
interfaces.
Coursework:
Discuss the major differences between the following
types of people of the DBMS environment.
i. Data administrator and Database Administrators
ii. Database Designers and Application Developers
iii. Naïve users and sophisticated users
DBMS ARCHITECTURE/DESIGN
A BDMS is divided into 3 levels,
usually referred to as:
external level,
internal level and
the conceptual level.
The external level
This is the level closest to the users. It is the one
concerned with the way data is seen by individual
users.
The end user is presented with special views that are
tailored to their specific needs. Some of these views
may be forms to fill out, others for interactive retrieval
of information, etc.
External level….
Provides a powerful and flexible security mechanism
by hiding parts of the DB from certain users. The user
is not aware of the existence of any attributes that are
missing from the view.
It permits users to access data in a way that is
customized to their needs, so that the same data can
be seen by different users in different ways, at the same
time.
The internal level
This is the closest to the physical storage. That is to
say, it is the one concerned with the way data is stored
inside the system (Physical representation of the DB
on the computer)
Physical implementation of the DB to achieve optimal
run– time performance and storage space utilization.
Storage space allocation for data and indexes
Record description for storage
Record placement
Data compression, encryption
The conceptual level
This is the level between the other two levels
◦ Description of the structure of the entire DB.
Hides the details of physical storage.
Concentrates on describing entities, data
types, relationships, user operations, and
constraints. In the relational model, this is
the base tables.
◦ Changes at this level can be made without
having any effect on the external level
Conceptual level…..
The logical structure of the entire database as seen by DBA.
What data is stored in the database.
The relationships among the data.
Complete view of the data requirements of the organization,
independent of any storage consideration.
Represents:
entities, attributes, relations
constraints on data
security, integrity information
Supports each external view: any data available to a user
must be contained in, or derivable from the conceptual level.
ILLUSTRATION OF THE ANSI-SPAC THREE-LEVEL
ARCHITECTURE
The way the users perceive the
data.
Mapping and independence between
external and internal levels.
The way the DBMS and OS perceive
the data.
Main Objective: separate each user’s view of the database from the way
it is physically represented.
Specific objectives of three-level
architecture
All users should be able to access same data.
A user's view is immune to changes made in other views.
Users should not need to know physical database storage
details.
DBA should be able to change database storage
structures without affecting the users' views.
Internal structure of database should be unaffected by
changes to physical aspects of storage.
DBA should be able to change conceptual structure of
database without affecting all users.
Data Independence
A major objective for the three-level architecture is to
provide data independence, which means that upper
levels are unaffected by changes to lower levels.
There are two kinds of data independence:
logical data independence
Physical data independence.
Logical data independence
Refers to the immunity of the external schemas to
changes in the conceptual schema.
Changes to the conceptual schema, such as the addition
or removal of new entities, attributes, or relationships,
should be possible without having to change existing
external schemas or having to rewrite application
programs.
Physical data independence
Refers to the immunity of the conceptual schema to
changes in the internal schema.
Changes to the internal schema, such as using different file
organizations or storage structures should be possible
without having to change the conceptual or external
schemas. From the users’ point of view, the only effect that
may be noticed is a change in performance.
In fact, deterioration in performance is the most common
reason for internal schema changes.
A Data Dictionary
This is an index of data held in the database. It is
used to assist in maintenance and any other access
of the database.
It provides a method for looking up data items
stored in the database. The data dictionary
contains the following:
A Data Dictionary
Field names, field types, length and the default value.
Example; a year field would be numerical, with four
digits and may have a default value of the current year.
Note that if these aspects are defined in a data
dictionary, they only need to be defined once no
matter how often they are applied by other programs
using the database.
Data and data models
A Data model is an integrated collection of concepts
or ideals for describing data, relationships between
data and constraints on the data in an organization.
Common definitions
Constraints are the rules enforced on data columns
on table. These are used to limit the type of data that
can go into a table. This ensures the accuracy and
reliability of the data in the database.
A database object in a relational database is a data
structure used to either store or reference data. The
most common object that people interact with is the
table. Other objects are indexes, views and many
more.
Types of data models
Data models are divided into three levels
1- conceptual model
2- logical model
3- physical model
Logical
Feature Conceptual Physical
Comparison btn the three types of data models
Entity Names ✓ ✓
Entity Relationships ✓ ✓
Attributes ✓
Primary Keys ✓ ✓
Foreign Keys ✓ ✓
Table Names ✓
Column Names ✓
Column Data Types ✓
Types of data models
The conceptual model
A conceptual data model identifies the highest-
level relationships between the different entities.
Features of conceptual data model include:
1. The important entities and the relationships among
them.
2. No attribute is specified.
3. No primary key is specified.
The figure below is an example of a
conceptual data model.
The Logical Model
A logical data model describes the data in as much
detail as possible, without regard to how they will be
physically implemented in the database. Features of a
logical data model include:
All entities and relationships among them.
All attributes for each entity are specified.
The primary key for each entity is specified.
Foreign keys (keys identifying the relationship
between different entities) are specified.
The steps for designing the logical data
model are as follows:
Specify primary keys for all entities.
Find the relationships between different
entities.
Find all attributes for each entity.
Resolve many-to-many relationships.
Normalization.
The figure below is an example of a
logical data model.
Logical data model Vs conceptual data
model diagrams
In a logical data model, primary keys are present, whereas in
a conceptual data model, no primary key is present.
In a logical data model, all attributes are specified within an
entity. No attributes are specified in a conceptual data
model.
Relationships between entities are specified using primary
keys and foreign keys in a logical data model. In a
conceptual data model, the relationships are simply stated,
not specified, so we simply know that two entities are
related, but we do not specify what attributes are used for
this relationship.
The physical model
Physical data model represents how the
model will be built in the database.
A physical database model shows all
table structures, including column
names, column data types, column
constraints, primary keys, foreign keys,
and relationships between tables.
Features of a physical data model
include:
Specification of all tables and columns.
Foreign keys are used to identify relationships between
tables.
Denormalization may occur based on user requirements.
Physical considerations may cause the physical data
model to be quite different from the logical data model.
Physical data model will be different for different
RDBMS. For example, data type for a column may be
different between MySQL and SQL Server.
The steps for physical data model
design are as follows:
Convert entities into tables.
Convert relationships into foreign
keys.
Convert attributes into columns.
Modify the physical data model based
on physical constraints / requirements.
The figure below is an example of a
physical data model.
END