1 Chapter 1 Updated
1 Chapter 1 Updated
Database System
Presented by
Dr. Md. Abir Hossain
Dept. of ICT
MBSTU
1
Book Reference
Book Name-> Introduction to database
management system
Writer-> Dr. Satinder Bal gupta and
Aditya Mittal
2
Introduction:
➢ A Data Base Management System is a software, system or program that allows access to data
contained in a database.
➢ The objective of the DBMS is to provide a convenient and effective method of defining, storing, and
retrieving the information stored in the database.
3
Figure 1: data processing
Information Attribute:
Three major attribute of information
➢ Accuracy
➢ free from errors, and it clearly and accurately reflects the meaning of data
➢ free from bias and conveys an accurate picture to the recipient
2. Timeliness
➢ recipients receive the information when they need it and within the required time frame.
3. Relevancy
➢ usefulness of the piece of information for the corresponding persons.
➢ Some information that is relevant for one person might not be relevant for another and vice versa e.g.,
the price of printer is irrelevant for a rickshaw puller.
4
Data and Information
Serial Data Information
Number
1. Data is unorganised and unrefined facts Information comprises processed, organised data
presented in a meaningful context
2. Data is an individual unit that contains raw Information is a group of data that collectively
materials which do not carry any specific carries a logical meaning.
meaning.
3. Data doesn’t depend on information. Information depends on data.
4. Raw data alone is insufficient for decision Information is sufficient for decision making
making
5. An example of data is a student’s test score The average score of a class is the information
derived from the given data.
5
Meta Data:
➢ Data about the data.
➢ Describe objects in the database and makes easier for those objects to be accessed or manipulated.
➢ Represent the database structure, sizes of data types, constraints, applications, authorization etc., that are
used as an integral tool for information resource management.
1. Descriptive meta data : It describes a resource for purpose such as discovery and identification. In a
traditional library cataloging that is form of meta data, title, abstract, author and keywords are examples of
meta data.
2. Structural meta data : It describes how compound objects are put together. The example is how pages are
ordered to form chapters.
3. Administrative meta data : It provides information to help manage a resource, such as when and how it was
created, file type and other technical information, and who can access it.
6
Database:
➢ Collection of interrelated data stored together with controlled redundancy
to serve one or more applications in an optimal way
➢ Collection of logically related data stored together that is designed to
meet information requirements of an organization.
➢ Databases are organized by fields, records and files.
1. Fields
➢ Smallest unit of the data and called data item or data element.
➢ Ex. Stu_Id, Stu_Name, Address and Telephone number
➢ Represented in the database by a value
2. Records Figure 2: Database
➢ collection of logically related fields and each field is possessing a fixed number of bytes and is of fixed
data type.
➢ One complete set of fields and each field have some value.
➢ Mainly two types: fixed length records and variable length records.
3. Files
➢ collection of related records.
➢ The records in a file may be of fixed length or variable length depending upon the size of the records
7
contained in a file.
Figure 3: Field, records, and file of a database
8
Database Management System (DBMS):
➢ A program or group of programs that work in conjunction with the operating system to create, process,
store, retrieve, control and manage the data.
➢ A computerized record-keeping system that stores information and allows the users to add, delete,
modify, retrieve and update that information.
The DBMS performs the following five primary functions :
1. Define, create and organize a database : The DBMS establishes the logical relationships among different
data elements in a database and also defines schemas and subschemas using the DDL.
2. Input data : It performs the function of entering the data into the database through an input device (like
data screen, or voice activated system) with the help of the user.
3. Process data : It performs the function of manipulation and processing of the data stored in the database
using the DML.
4. Maintain data integrity and security : It allows limited access of the database to authorized users to
maintain data integrity and security.
5. Query database : It provides information to the decision makers that they need to make important
decisions. This information is provided by querying the database using SQL. 9
Components of database:
➢ Three main components of DBMS are Data Definition
Language (DDL), Data Manipulation Language and Query
Facilities (DML/SQL), and software for controlled access of
Database.
2. Data Inconsistency
➢ Data redundancy leads to data inconsistency especially when data is not to be updated.
➢ Data inconsistency occurs due to the same data items that appear in more than one file do not get
updated simultaneously in each and every file.
➢ Ex. an employee is promoted from Clerk to Superintendent and the same is immediately updated in
the payroll file may not necessarily be updated in provident fund file. This results in two different
designations of an employee at the same time leads inconsistency.
5. Data Dependence
➢ The Applications/programs in file processing system are data dependent
➢ The file organization, its physical location and retrieval from the storage media are dictated by the
requirements of the particular application.
➢ For example, in payroll application, the file may be organized on employee records sorted on their last
name, which implies that accessing of any employee’s record has to be through the last name only.
8. Problem of Security
➢ It is very difficult to enforce security checks and access rights in a traditional file system, since
application programs are added in an ad-hoc manner.
13
Database Systems or Database System environment:
The DBMS software together with the Database is called a database system. In other words, it can be defined as an organization
of components that define and regulate the collection, storage, management and use of data in a database.
1. Data
➢ The whole data in the system is stored in a single database.
➢ This data in the database are both shared and integrated.
➢ Sharing of data means individual pieces of data in the
database is shared among different users
2. Hardware
➢ Hardware consists of the secondary storage devices like
disks, drums where the database stored.
➢ There is two types of hardware. The first one is processor
and main memory that supports in running the DBMS.
➢ The second one is the secondary storage devices, i.e., hard
disk, magnetic disk etc., that are used to hold the stored
data.
3. Software
➢ A layer or interface of software exists between the physical
database and the users. This layer is called the DBMS. 14
Figure 5: Database system
4. Users
➢ The users are the people interacting with the database system.
➢ There are four types of users interacting with the database systems. These are Application
Programmers, online users, end users or naive users and finally the Database Administrator (DBA).
DBMS Users:
1. End users or Naive users: The end users or naive users use the database system through a menu-oriented
application program, where the type and range of response is always displayed on the screen. A user of an
ATM falls in this category.
2. Online users: These type of users communicate with the database directly through an online terminal or
indirectly through an application program and user interface.
3. Application Programmers: These are the professional programmers or software developers who develop the
application programs or user interfaces for the naive and online users. These programmers must have the
knowledge of programming languages such as Assembly, C, C++, Java, or SQL, etc., since the application
programs are written in these languages.
4. Database Administrator: DBA is a person who have complete control over database of any enterprise.. He is
concerned with the Back-End of any project. 15
Advantages of database management systems:
1. Controlled redundancy : In a database system, this duplication is carefully controlled, that means the
database system is aware of the redundancy and it assumes the responsibility for propagating updates.
2. Data consistency : The problem of updating multiple files in traditional file system leads to inaccurate data
as different files may contain different information of the same data item at a given point of time. This causes
incorrect or contradictory information to its users. In database systems, this problem of inconsistent data is
automatically solved by controlling the redundancy.
3. Program data independence : The traditional file systems are generally data dependent, which implies that
the data organization and access strategies are dictated by the needs of the specific application and the
application programs are developed accordingly. However, the database systems provide an independence
between the file system and application program, that allows for changes at one level of the data without
affecting others.
16
4. Sharing of data : In database systems, the data is centrally controlled and can be shared by all authorized
users. The sharing of data means not only the existing applications programs can also share the data in the
database but new application programs can be developed to operate on the existing data.
5. Enforcement of standards : In database systems, data being stored at one central place, standards can
easily be enforced by the DBA. This ensures standardized data formats to facilitate data transfers between
systems.
6. Improved data integrity : Data integrity means that the data contained in the database is both accurate and
consistent. The centralized control property allow adequate checks can be incorporated to provide data
integrity.
7. Improved security : Database security means protecting the data contained in the database from
unauthorized users. The DBA ensures that proper access procedures are followed, including proper
authentical schemes for access to the DBMS and additional checks before permitting access to sensitive data.
8. Data access is efficient : The database system utilizes different sophisticated techniques to access the
stored data very efficiently.
9. Conflicting requirements can be balanced : The DBA resolves the conflicting requirements of various users
and applications by knowing the overall requirements of the organization. 17
10. Improved backup and recovery facility : Through its backup and recovery subsystem, the database system
provides the facilities for recovering from hardware or software failures.
11. Minimal program maintenance : In a traditional file system, the application programs with the description
of data and the logic for accessing the data are built individually. These are reduced to minimal in database
systems due to independence of data and application programs.
12. Data quality is high : The quality of data in database systems are very high as compared to traditional file
systems. This is possible due to the presence of tools and processes in the database system.
13. Good data accessibility and responsiveness : The database systems provide query languages or report
writers that allow the users to ask ad hoc queries to obtain the needed information immediately, without the
requirement to write application programs (as in case of file system), that access the information from the
database.
14. Concurrency control : The database systems are designed to manage simultaneous (concurrent) access of
the database by many users.
15. Economical to scale : In database systems, the operational data of an organization is stored in a central
database. The application programs that work on this data can be built with very less cost as compared to
traditional file system. 18
16. Increased programmer productivity : The database system provides many standard functions that the
programmer would generally have to write in file system. The availability of these functions allow the
programmers to concentrate on the specific functionality required by the users without worrying about the
implementation details. This increases the overall productivity of the programmer and also reduces the
development time and cost.
Disadvantages of DBMS:
1. Complexity increases : The data structure may become more complex because of the centralized database
supporting many applications in an organization.
2. Requirement of more disk space : The wide functionality and more complexity increase the size of DBMS.
Thus, it requires much more space to store and run than the traditional file system.
3. Additional cost of hardware : The cost of database system’s installation is much more. It depends on
environment and functionality, size of the hardware and maintenance costs of hardware.
4. Cost of conversion : The cost of conversion from old file-system to new database system is very high.
19
5. Need of additional and specialized manpower : Any organization having database systems, need to be hire
and train its manpower on regular basis to design and implement databases and to provide database
administration services.
6. Need for backup and recovery : For a database system to be accurate and available all times, a procedure is
required to be developed and used for providing backup copies to all its users when damage occurs.
7. Organizational conflict : A centralized and shared database system requires a consensus on data definitions
and ownership as well as responsibilities for accurate data maintenance.
8. More installation and management cost : The big and complete database systems are more costly. They
require trained manpower to operate the system and has additional annual maintenance and support costs.
20
Database administrator:
Database Administrator (DBA) is a person who have complete control over database of any enterprise. He is
concerned with the Back-End of any project. Some of the main responsibilities of DBA are as follows :
1. Deciding the conceptual schema or contents of database : DBA decides the data fields, tables, queries, data
types, attributes, relations, entities or you can say that he is responsible for overall logical design of database.
2. Deciding the internal schema of structure of physical storage : DBA decides how the data is actually stored
at physical storage, how data is represented at physical storage(physical environment).
3. Deciding users : DBA gives permission to users to use database. Without having proper permission, no one
can access data from database.
4. Deciding user view : DBA decides different views for different users.
5. Granting of authorities : DBA decides which user can use which portion of database. User can use only that
data on which access right is granted to him.
6. Deciding constraints : DBA decides various constraints over database for maintaining consistency and
validity in database.
7. Security : Security is the major concern in database. DBA takes various steps to make data more secure
against various disasters and unauthorized access of data. 21
8. Monitoring the performance : DBA is responsible for overall performance of database. DBA regularly
monitors the database to maintain its performance and try to improve it.
9. Backup : DBA takes regular backup of database, so that it can be used during system failure. Backup is also
used for checking data for consistency.
10. Removal of dump and maintain free space : DBA is responsible for removing unnecessary data from
storage and maintain enough free space for daily operations. He can also increase storage capacity when
necessary.
11. Checks : DBA also decides various security and validation checks over database to ensure consistency.
12. Liaisioning with users : Another task of the DBA is to liaisioning with users and ensure the availability of
the data they require and write the necessary external schemas.
22
DBMS languages:
The following five languages are available to specify different schemas.
1. Data Definition Language (DDL) 2. Storage Definition Language (SDL)
3. View Definition Language (VDL) 4. Data Manipulation Language (DML)
5. Fourth-Generation Language (4-GL)
1. Data Definition Language (DDL): It is used to specify a database conceptual schema using set of definitions.
2. Storage Definition Language (SDL): It is used to specify the internal schema in the database. The storage
structure and access methods used by the database system is specified by the specified set of SDL statements.
3. View Definition Language (VDL): It is used to specify user’s views and their mappings to the conceptual
schema. But generally, DDL is used to specify both conceptual and external schemas in many DBMS’s.
4. Data Manipulation Language (DML): It provides a set of operations to support the basic data manipulation
operations on the data held in the database. It is used to query, update or retrieve data stored in a database.
The DML is of the two types :
(i) Procedural DML : It allows the user to tell the system what data is needed and how to retrieve it.
(ii) Non-procedural DML : It allows the user to state what data are needed, rather than how it is to be retrieved.
23
Fourth generation language (4GL):
It is a compact, efficient and non-procedural programming language used to improve the efficiency and
productivity of the DBMS. The 4-GL has the following components in it. These are :
• Subschema
➢ A subschema is a subset of the schema having the same properties that a schema has.
➢ The subschema allows the user to view only that part of the database that is of interest to him.
• Instances
➢ The data in the database at a particular moment of time is called an instance or a database state.
➢ In a given instance, each schema construct has its own current set of instances. The Figure below
shows an instance of the ITEM relation in a database schema.
26
Figure 7: An instance/database state of the ITEM relation.
Three level architecture of database systems :
The architecture is a framework for describing database concepts and specifying the structure of database
system. A database can be divided into three levels: external level, conceptual level and internal level
(i) Internal Level
➢ Internal level describes the actual physical
storage of data or the way in which the data is
actually stored in memory.
➢ This level is not relational because data is
stored according to various coding schemes
instead of tabular form (in tables).
The internal level is concerned with the following
aspects:
– Storage space allocation
– Access paths
– Data compression and encryption techniques
– Record placement etc.
27
Figure 8: Three level architecture of DBMS.
(ii) Conceptual Level
➢ The conceptual level is also known as logical level which describes the overall logical structure of whole database
for a community of users.
➢ This level is relational because data visible at this level will be relational tables and operators.
➢ This level represents entire contents of the database in an abstract form in comparison with physical level
28
Data Models:
A data model is a collection of concepts that can be used to describe the structure of the database including
data types, relationships and the constraints that apply on the data.
29
Types of data models:
The various data models can be divided into three categories, such as,
(i) Record Based Data Models : These models represent data by using the record structures. These data
models can be further categorised into three types:
(a) Hierarchical Data Model
(b) Network Data Model
(c) Relational Data Model.
(ii) Object Based Data Models : These models are used in describing the data at the logical and user view
levels. These data models can be further categorized into four types:
(a) Entity Relationship Model (ER-Model)
(b) Object Oriented Model
(c) Semantic Data Model
(d) Functional Data Model.
30
(iii) Physical Data Models : These models provide the concepts that describes the details of how the data is
stored in the computer along with their record structures, access paths and ordering. These data models can
be divided into two types:
(a) Unifying Model.
(b) Frame Memory Model.
31
• Network Data Model :
➢ Able to handle many to many (N : N) relations between its records is the main distinguishing feature
from the hierarchical model.
➢ Thus, this model permits a child record to have more than one parent.
➢ Directed graphs are used instead of tree structure in which a node can have more than one parent.
➢ The relationships between specific records of 1 : 1 (one to one), 1 : N (one to many) or N : N (many
to many) are explicitly defined in database definition of this model.
➢ There are two basic data structures in this model—Records and Sets.
32
• Relational data Model :
➢ Most popular developments in the database technology because it can be used for representing
most of the real world objects and the relationships between them.
➢ The main significance of the model is the absolute separation of the logical view and the physical
view of the data.
➢ The physical view in relational model is implementation dependent and not further defined.
➢ The logical view of data in relational model is set oriented.
➢ A relational set is an unordered group of items.
➢ The field in the items are the columns. The column in a table have names. The rows are unordered
and unnamed.
➢ A database consists of one or more tables plus a catalogue describing the database.
34
➢ Object-Oriented Data Model :
➢ A logical data model that captures the semantics of objects supported in an object-oriented
programming.
➢ It is based on collection of objects, attributes and relationships which together form the static
properties.
➢ An object is a collection of data and methods. When different objects of same type are grouped
together they form a class.
➢ The object model is represented graphically with object diagrams containing object classes.
➢ Classes are arranged into hierarchies sharing common structure and behavior and are associated
with other classes.
From the available record based data models, the relational data model is most commonly used model by
most of the organizations because of the following reasons:
36
1. It increases the productivity of application programmers in designing the database. Whenever changes
are made to the database there is no need of changing the application programs because of separation of
logical level from conceptual level.
2. It is useful for representing most of the real world objects and relationships between them.
3. It provides very powerful search, selection and maintenance of data.
4. It hides the physical level details from the end users so end users are not bothered by physical storage.
5. It provides data integrity and security so that data is not accessed by unauthorized users and data is
always accurate.
6. It provides ad hoc query capability.
37
Comparison of Various Data Models
The most commonly used data models are compared on the basis of various properties. The comparison
table is given below.
38
Types of database systems:
The database systems can be classified into three categories
(i) According to the number of users
(ii) According to the type of use
(iii) According to database site locations
1. According to the Number of users:
According to the number of users, the database systems can
be further subdivided into two categories, namely:
(a) Single-user database systems
(b) Multiuser database systems.
(a) Single-user database systems :
➢ The database reside on a PC on the hard disk.
➢ All the applications run on the same PC and directly access the database. Figure 9: Singe user database
➢ In single user database systems, the application is the DBMS.
➢ A single user database system is shown in figure 9.
39
(b) Multiuser database systems :
➢ many PC’s are connected through a Local
Area Network (LAN) and a file server
stores a copy of the database files.
➢ Each PC on the LAN is given a volume
name on the file server.
➢ Applications run on each PC that is
connected to the LAN and access the
same set of files on the file server.
➢ The applications must handle the
concurrency control and the business
rules are enforced in the application.
➢ The example is MS-Access or Oracle files
on a file server. A multiuser database
system is shown in figure 10.
40
Advantages of Multiuser Database System
There are many advantages of multiuser database system. Some of them are as follows:
(i) Ability to share data among various users.
(ii) Cost of storage is now divided among various users.
(iii) Low cost since most components are now commodity items.
41
(a) Production or Transactional Database Systems :
➢ The production database systems are used for management of supply chain and for tracking
production of items in factories, inventories of items in warehouses/stores and orders for items.
➢ The transactional database systems are used for purchases on credit cards and generation of
monthly statements.
➢ They are also used in Banks for customer information, accounts, loans and banking transactions.
(b) Decision Support Database Systems :
➢ Decision support database systems are interactive, computer-based systems that aid users in
judgement and choice activities.
➢ They provide data storage and retrieval but enhance the traditional information access and retrieval
functions with support for model building and model based reasoning.
➢ They support framing, modelling and problem solving.
➢ Typical application areas of DSS’s are management and planning in business, health care, military and
any area in which management will encounter complex decision situations.
(c) Data Warehouses :
➢ A data warehouse is a relational database management system (RDBMS) designed specifically to
meet the transaction processing systems.
➢ It can be loosely defined as any centralized data repository which can be queried for business
benefit.
42
3. According to Database Site
Locations:
(a) Centralized database systems
(b) Parallel database systems
(c) Distributed database systems
(d) Client/Server database systems
(a) Centralized database systems :
➢ It consists of a single processor together with its
associated data storage devices and other
peripherals.
➢ Multiple users access the applications through simple
terminals that have no processing power of their own.
➢ The user interface is text-mode screens and the
business rules are enforced in the applications
running on the mainframe or PC.
➢ The example of centralized database system is DB2
database and Cobol application programs running on
IBM 390. Figure 11: centralized Database system
43
(b) Parallel database systems :
➢ A parallel database system can be defined as a database system implemented on a tightly coupled
multiprocessor or on a loosely coupled multiprocessor.
➢ Parallel database systems link multiple smaller machines to achieve the same throughput as a single
larger machine, often with greater scalability and reliability than single processor database system.
There are three main architectures for parallel database system.
(i) Shared memory architecture
(ii) Shared disk architecture
(iii) Shared nothing architecture
44
Figure 12: Distributed Database
45
(d) Client/Server Database System :
➢ The server acts as a whole data base management system and some clients or personal computers
which are connected with server through a network interface. The complete architecture is shown
below:
46
Components of Client-Server Architecture
There are three major components of client server architecture:
1. Server
2. Client
3. Network interface
1. Server :
➢ Server is DBMS itself.
➢ It consists of DBMS and supports all basic DBMS functions.
➢ Server components of DBMS are installed at server.
➢ It acts as monitor of all of its clients.
Functions of Server : The server performs various functions, which are as follows.
1. It supports all basic DBMS functions.
2. Monitor all his clients.
3. Distribute work-load over clients.
4. Solve problems which are not solved by clients.
5. Maintain security and privacy.
6. Avoiding unauthorized access of data.
47
2. Clients :
➢ Client machine is a personal computer or workstation which provide services to both server and users.
➢ It must obey his server.
➢ Client components of DBMS are installed at client site.
➢ Clients are taking instructions from server and help them by taking their load.
➢ When any user want to execute a query on client, the client first take data from server then execute the
query on his own hardware and returns the result to the server.
3. Network Interface :
➢ Clients are connected to server by network interface.
➢ It is useful in connecting the server interface with user interface so that server can run his applications
over his clients.
48
Comparison Between client/server and distributed
database System
49
50