You are on page 1of 48

Unit I

Introduction to
DBMS
1.1Database Management System
(DBMS)

Database:
Definition: Database is a collection of data
stored in a standardized format to be shared
by multiple users.
DBMS:
Definition: DBMS is software that defines a
database, stores the data, supports a query
language, produces reports and creates data
entry screens.
Advantage of DBMS

• Minimal data redundancy


• Data consistency
• Integration of data
• Sharing of data
• Enforcement of standards
• Ease of application development
• Uniform security, privacy and integrity
• Data independence
File system

•  Is a method of storing and arranging


computer files and the information in
the file (data).
• Also a computer based system
• Information is stored in different
computer files.
Characteristics of file system

• It stores data of an organization in group of files.


• Files carrying data are independent on each
other.
• COBOL, C, C++ programming languages were
used to design the files.
• It is less flexible and has many limitations.
• It is very difficult to maintain file processing
system.
• File in Traditional File Processing Systems are
called flat files.
Common problems with using file
system

Uncontrolled duplication
hard to update all files
Inconsistent data
Inflexibility(hard to change data and programs
Limited data sharing
Poor enforcement of standards
Poor programmer productivity
Excessive program maintenance
1.2 DBMS vs. File System
File Management System Database Management System

• File System is a general, easy-to-use system to


• Database management system is used when security constraints
store general files which require less security
are high.
and constraints.

• Data Redundancy is more in file management


• Data Redundancy is less in database management system.
system.

• Data Inconsistency is more in file system. • Data Inconsistency is less in database management system.

• Centralization is hard to get when it comes to


• Centralization is achieved in Database Management System.
File Management System.

• User locates the physical address of the files to • In Database Management System, user is unaware of physical
access data in File Management System. address where data is stored.

• Security is low in File Management System. • Security is high in Database Management System.

• File Management System stores unstructured • Database Management System stores structured data which
data as isolated data files/entities. have well defined constraints and interrelation.
1.3 View of data
1. Data abstraction
2. Instances and schemas
3. Data models
Data abstraction
• Database systems are made-up of
complex data structures. 
• To ease the user interaction with
database, the developers hide internal
irrelevant details from users. This process
of hiding irrelevant details from user is
called data abstraction.
Levels of abstraction
1. Physical level:
• This is the lowest level of data
abstraction. 
• It describes how data is actually stored
in database.
• We can get the complex data structure
details at this level.
2. Logical level
• This is the middle level of 3-level data
abstraction architecture. 
•  It describes what data is stored in
database.
3. View level
• Highest level of data abstraction. 
• Highest level of data abstraction. 
Instances and schemas
• The data stored in database at a particular
moment of time is called instance of database. 
• Design of a database is called the schema. 
• Schema is of three types: Physical schema,
logical schema and view schema.
•  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.
Example of schema
• For example, we have a schema that shows the
relationship between three tables: Course, Student and
Section. The diagram only shows the design of the
database, it doesn’t show the data present in those
tables. Schema is only a structural view(design) of a
database as shown in the diagram below.
cntd…
• The design of a database at physical level is called physical
schema, how the data stored in blocks of storage is described at
this level.
• Design of database at logical level is called logical schema,
programmers and database administrators work at this level, at
this level data can be described as certain types of data records
gets stored in data structures, however the internal details such
as implementation of data structure is hidden at this level
(available at physical level).
• Design of database at view level is called view schema. This
generally describes end user interaction with database systems.
Example of Instances
• For example,
lets say we have a single table student in the
database, today the table has 100 records, so
today the instance of the database has 100
records. Lets say we are going to add another
100 records in this table by tomorrow so the
instance of database tomorrow will have 200
records in table. In short, at a particular moment
the data stored in database is called the
instance, that changes over time when we add or
delete data from the database.
1.4 Data models
• Data Model is a logical structure of Database.
• It describes the design of database to reflect entities,
attributes, relationship among data, constrains etc.
Relational model:
• In relational model, the data and
relationships are represented by
collection of inter-related tables.
• Each table is a group of column and
rows, where column represents attribute
of an entity and rows represents records.
Entity relationship model
• Describes the structure of a database with the
help of a diagram, which is known as Entity
Relationship Diagram (ER Diagram). 
• An ER model is a design or blueprint of a
database that can later be implemented as a
database.
• The main components of E-R model are: entity
set and relationship set.
Object based data model
• Object based data models use concepts such
as entities, attributes, and relationships.
• Some of the more common types of object
based data model are:
o Entity-Relationship
o Object Oriented
o Semantic
o Functional
Semi structured model
• Is a database model where there is no
separation between the data and the
schema.
• the amount of structure used depends
on the purpose.
1.5 Database language
• Database languages are used to read, update
and store data in a database.
• There are several such languages that can be
used for this purpose; one of them is SQL
(Structured Query Language).
• Types of database languages are:
1. DML
Data Manipulation Language
2. DDL
Data Definition Language
Data Definition Language (DDL)
• DDL is used for specifying the database schema.
• It is used for creating tables, schema, indexes,
constraints etc. in database.
• Operations in database that comes under DDL 
o To create the database instance – CREATE
o To alter the structure of database – ALTER
o To drop database instances – DROP
o To delete tables in a database instance – TRUNCATE
o To rename database instances – RENAME
o To drop objects from database such as tables – DROP
o To Comment – Comment
Data Manipulation Language (DML)
• DML is used for accessing and manipulating
data in a database.
• The following operations on database comes
under DML:
o To read records from table(s) – SELECT
o To insert record(s) into the table(s) – INSERT
o Update the data in table(s) – UPDATE
o Delete all the records from the table – DELETE
1.6 Database users and
database administrators
People who are working with the database can be
categorized into two:

A. Database users: Database users are the


persons who interact with the database and
take the benefits of database.

B. Database administrators: Database


Administrators coordinate all the activities of the
database system. They have all the permissions.
Database users types
1. Native Users
• These are the database users who are
communicating with the database through
an already written program.
• For example, when a student is registering
on a website for an online examination. He
creates data in the database by entering
and submitting his name, address and
exam details.
2. Application Programmers
• These are the software developers and programming
professionals who write the program codes.
• They use tools like Rapid Application Development
(RAD) tools for creating user interfaces with minimal
efforts.
3.  Sophisticated Users
• Sophisticated users are those who are creating the
database. These type of users do not write program
code. And they do not use any software to request the
database.
• The sophisticated users directly interact with the
database system using query languages like SQL.
4. Specialized Users 
• The sophisticated users who write
special database application programs are
called specialized users. The write
complex programs for the specific complex
requirements.
5. Stand-alone Users
• Those who are using database fo personal
usage. There are many database
packages for this type database users.
Types of database administrator(DBA)

• The person who has the central control over a


database system is called Database
Administrator (DBA).
• Tasks/ functions of DBA
 Schema Definition: The database administrator
creates the original database schema by
executing a set of data definition statements in
DDL.
 Storage structure an access method
definition.
 Schema and physical or organization
modification: The database administrator performs the
changes to the schema according to the needs of
organizations or physical needs to improve the database
performance.
 Provide the granting of authorization to access
data: The database administrator can decide the which
parts of the database can be accessed by a user, by
using the different types of authorization methods.
 Database maintenance: The database
maintenance includes the following processes.
• Regular backing up of the database.
• Ensuring the disk space for performing the required
operations.
• Monitoring the jobs running on the database.
1.7 Transaction management
• A transaction is a logical unit of processing in a
DBMS which entails one or more database
access operation. 
• All types of database access operation which
are held between the beginning and end
transaction statements are considered as a
single logical transaction. During the transaction
the database is inconsistent. Only once the
database is committed the state is changed from
one consistent state to another.
• The transaction is executed as a single unit.
If the database operations do not update the
database but only retrieve data, this type of
transaction is called a read-only transaction.
A successful transaction can change the
database from one consistent state to another.
State of transactions

State Transaction types


Active State A transaction enters into an active state when the execution process begins. During this state
read or write operations can be performed.

Partially Committed A transaction goes into the partially committed state after the end of a transaction.

Committed State When the transaction is committed to state, it has already completed its execution successfully.
Moreover, all of its changes are recorded to the database permanently.

Failed State A transaction considers failed when any one of the checks fails or if the transaction is aborted
while it is in the active state.

Terminated State State of transaction reaches terminated state when certain transactions which are leaving the
system can't be restarted.
State Transition Diagram for a
Database Transaction
ACID Properties
For maintaining the integrity of data, the DBMS system you have to
ensure ACID properties. ACID stands
for Atomicity, Consistency, Isolation, and Durability.
• Atomicity: A transaction is a single unit of operation. You either
execute it entirely or do not execute it at all. There cannot be partial
execution.
• Consistency: Once the transaction is executed, it should move
from one consistent state to another.
• Isolation: Transaction should be executed in isolation from other
transactions (no Locks). During concurrent transaction execution,
intermediate transaction results from simultaneously executed
transactions should not be made available to each other. (Level
0,1,2,3)
• Durability: · After successful completion of a transaction, the
changes in the database should persist. Even in the case of system
failures.
What is serializability?
Serializability is the process of search for a
concurrent schedule who output is equal to
a serial schedule where transaction ae
execute one after the other. Depending on
the type of schedules, there are two types of
serializability:
• Conflict
• View
1.8 Database system structure
• DBMS (Database Management System)
acts as an interface between the user and
the database. The user requests the
DBMS to perform various operations
(insert, delete, update and retrieval) on the
database. The components of DBMS
perform these requested operations on the
database and provide necessary data to
the users.
fig. structure of DBMS
Components of DBMS
1. DDL Compiler - Data Description Language compiler
processes schema definitions specified in the DDL. It includes
metadata information such as the name of the files, data items,
storage details of each file, mapping information and constraints
etc.
2. DML Compiler and Query optimizer - The DML commands
such as insert, update, delete, retrieve from the application
program are sent to the DML compiler for compilation into object
code for database access. The object code is then optimized in
the best way to execute a query by the query optimizer and then
send to the data manager.
3. Data Manager - The Data Manager is the central software
component of the DBMS also knows as Database Control
System.
4. Data Dictionary - Data Dictionary is a repository of
description of data in the database. It contains information about
• Data - names of the tables, names of attributes of each table,
length of attributes, and number of rows in each table.
• Relationships between database transactions and data items
referenced by them which is useful in determining which
transactions are affected when certain data definitions are
changed.
• Constraints on data i.e. range of values permitted.
• Detailed information on physical database design such as
storage structure, access paths, files and record sizes.
• Access Authorization - is the Description of database users
their responsibilities and their access rights.
• Usage statistics such as frequency of query and transactions.
• Data dictionary is used to actually control the data integrity,
database operation and accuracy. It may be used as a
important part of the DBMS.
5. Data Files - It contains the data portion of
the database.
6. Compiled DML - The DML complier
converts the high level Queries into low level
file access commands known as compiled
DML.
7. End Users -
1.9 Application architectures
• The design of a DBMS depends on its
architecture.
•  It can be centralized or decentralized or
hierarchical. 
• DBMS architecture helps in design,
development, implementation, and
maintenance of a database.
1-tier architecture
• The simplest of Database Architecture
are 1 tier where the Client, Server, and
Database all reside on the same machine.
• Anytime you install a DB in your system
and access it to practice SQL queries it is
1 tier architecture.
• But such architecture is rarely used in
production.
2-tier architecture
• A two-tier architecture is a database architecture where
• Presentation layer runs on a client (PC, Mobile, Tablet,
etc)
• Data is stored on a Server.
• An application interface which is called ODBC (Open
Database Connectivity) an API which allows the client-
side program to call the DBMS. Today most of the DBMS
offers ODBC drivers for their DBMS. 2 tier architecture
provides added security to the DBMS as it is not
exposed to the end user directly.
Example of Two-tier Architecture is a Contact Management
System created using MS- Access.

• In the above 2-teir architecture we can see that one


server is connected with clients 1, 2 and 3. This
architecture provides Direct and faster communication.
3-tier architecture
• 3-tier schema is an extension of the 2-tier
architecture
• . Database (Data) Tier − At this tier, the database resides
along with its query processing languages. We also have the
relations that define the data and their constraints at this level.
• Application (Middle) Tier − At this tier reside the application
server and the programs that access the database. For a
user, this application tier presents an abstracted view of the
database. End-users are unaware of any existence of the
database beyond the application. At the other end, the
database tier is not aware of any other user beyond the
application tier. Hence, the application layer sits in the middle
and acts as a mediator between the end-user and the
database.
• User (Presentation) Tier − End-users operate on this tier and
they know nothing about any existence of the database
beyond this layer. At this layer, multiple views of the database
can be provided by the application. All views are generated by
applications that reside in the application tier.
Goals of 3 tier architecture
• To separate the user applications and
physical database
• Proposed to support DBMS characteristics
• Program-data independence
• Support of multiple views of the data

You might also like