DBMS
DBMS
3
Advantages of DBMS
• Segregation of application program.
• Minimal data duplicity or data redundancy.
• Easy retrieval of data using the Query Language.
• Reduced development time and maintenance need.
• With Cloud Datacenters, we now have Database Management
Systems capable of storing almost infinite data.
• Seamless integration into the application programming
languages which makes it very easier to add a database to
almost any application or website.
4
Disadvantages of DBMS
• It's Complexity
• Except MySQL, which is open source, licensed DBMSs are
generally costly.
• They are large in size.
5
Applications of DBMS
Database is widely used. The some of the representative applications are:
• Banking: for customer information, accounts and loans and banking transactions.
• Universities: for student registrations and grades.
• Online shopping: Everyone wants to shop from home. Everyday new products are added and sold only
with the help of DBMS. Purchase information, invoice bills and payment, all of these are done with the
help of DBMS.
• Airlines: for reservations and schedule information.
• Credit Card Transactions: for purchases on credit cards and generation of monthly statements.
• Library Management System: maintain all the information relate to book issue dates, name of the
book, author and availability of the book.
• Telecommunications: for keeping records of call made, generating monthly bills, maintaining balances
on prepaid calling cards.
• Sales: for customer, product and purchase information.
• Finance: for storing information about holdings, sales, and purchases of financial instruments such as
stocks and bonds.
• Manufacturing: for management of supply chain and for tracking production of items in factories,
inventories of items and orders for items.
• Human Resource: for information about employees, salaries, payroll taxes and benefits.
6
Components of DBMS
• The database management system can be divided into five
major components, they are:
• Hardware
• Software
• Data
• Procedures
• Database Access Language
• Let's have a simple diagram to see how they all fit together to
form a database management system.
Cont….
7
Cont..
8
DBMS Components: Hardware
• When we say Hardware, we mean computer, hard disks, I/O channels for
data, and any other physical component involved before any data is
successfully stored into the memory.
• When we run Oracle or MySQL on our personal computer, then our
computer's Hard Disk, our Keyboard using which we type in all the
commands, our computer's RAM, ROM all become a part of the DBMS
hardware.
DBMS Components: Software
• This is the main component, as this is the program which controls
everything. The DBMS software is more like a wrapper around the physical
database, which provides us with an easy-to-use interface to store, access
and update data.
• The DBMS software is capable of understanding the Database Access
Language and interpret it into actual database commands to execute them
on the DB.
Cont..
9
DBMS Components: Data
• Data is that resource, for which DBMS was designed. The motive behind the creation of DBMS was to store
and utilize data.
• In a typical Database, the user saved Data is present and meta data is stored.
Metadata is data about the data. This is information stored by the DBMS to better understand the data stored
in it.
• For example: When I store my Name in a database, the DBMS will store when the name was stored in the
database, what is the size of the name, is it stored as related data to some other data, or is it independent,
all this information is metadata.
10
11 Dr. E. F. Codd’s
Rules for RDBMS
Dr. E.F. Codd was an IBM
researcher who first developed
the relational data model in
1970. In 1985 Dr. E.F. Codd
published a list of 12 rules that
define an ideal relational
database and has provided a
guide line for the design of all
relational database systems.
Dr. Codd has used the term
guideline because till date no
commercial relational database
system fully conforms to all 12
rules.
Rule 1: The Information Rule
12
Rule No. 2: Guaranteed Access
Rule
All Data should be accessible without ambiguity.
This can be accomplished through the combination
of table name, primary key, and column name.
13
Rule No. 3: Systematic treatment
of null values
A field should be allowed to remain empty. This involves the
support of null value, which is distinct from an empty string or
a number with a value of zero. Of course this can not apply to
primary keys.
14
Rule No. 4: Dynamic online catalog
based on the relational model
A relational database must provide access to its
structure through the same tools that are used to
access data. This is usually accomplished by storing
the structure definition within special system tables.
15
Rule No. 5: Comprehensive Data sub- 16
language Rule
Data can be
presented in
different logical
combinations
called views. Each
view should
support the same
full range of data
manipulation that
has direct access
to a table
available.
17
Rule No. 7: High-level Insert,
Update, and Delete
Data can be retrieved from a relational database in
sets constructed of data from multiple rows and /or
multiple tables. This rules states that insert, update
and delete operations should be supported for any
retrievable set rather than just for a single row in a
single table.
18
Rule no. 8: Physical Data Independence 19
22
Rule no. 12: Non subversion
Rule
24
File System Database
(like data in text file as in C programs ) System
Data As data are scattered in different files and file may be of Uniformity in the
Isolation different formats as some in .doc or .txt or .xls need way data is stored
require coding for each of them.
Integrity Data values must follow some consistency constraint New constraint can
problems such as no account should have less than Rs 5000. in File easily be add,
System we need to code it and if in future we want to modify & drop
change it we need to recode it! easily.
• Integrity constraints (e.g. account balance > 5000)
become part of program code
• Hard to add new constraints or change existing ones
Inconsistency Computer systems are prone to failures. Suppose a Atomicity can
and program transferring Rs 5000 from account A to B but in easily be
Atomicity middle system crash then Rs 5000 was removed from maintained, these
but not credited to B. This lead to inconsistent state. It is system have
Problem
difficult to ensure atomicity in File system. recovery and back
• Transfer of funds from one account to another up tools.
should either complete or not happen at all
25
File System Database System
(like data in text file as in C programs )
Concurrent Consider an account A holding $500, if two Support multi-user
- access customer C1 & C2 withdraw $100 and $50 from system.
anomalies A simultaneously then initially C1 & C2 see $500
now whichever write last it either show $400 or
$450 while correct is $350.
Hence File system have greater challenge as
many application programs access same data
simultaneously in multi-user system.
Security Enforcing security constraint is difficult. Database has
problem As faculty can upload and see attendance of internal procedures
student, whereas and commands for
only class advisor can modify already uploaded this.
attendance and
students can only see their own attendance.
26
Schema and Instance
• Similar to types and variables in programming languages
• Schema – the logical structure of the database
• the overall design of the database
• e.g., the database consists of information about a set of customers
and accounts and the relationship between them)
• Analogous to type information of a variable in a program
• Physical schema: database design at the physical level
• Logical schema: database design at the logical level
• Instance – the actual content of the database at a particular
point in time
• Analogous to the value of a variable
27
Data Abstraction
• For the system to be usable, it must retrieve data
efficiently.
• The need for efficiency has led designers to use
complex data structures to represent data in the
database.
• Developers hide the complexity from users through
several levels of abstraction to simplify users’
interactions with the system.
• It follows three Schema Architecture:
• Physical Level
• Logical Level
• View level
28
Three Schema Architecture
END User
Forms, Login Pages,
Command prompt External View External View External View
29
• Physical level
• Has an internal schema
• Describes the physical storage structure of the database
• Data structure used to store data
• Access paths for database
• The lowest level of abstraction describes how the data are actually
stored.
• Conceptual level
• The next-higher level of abstraction describes what data are stored
in the database, and what relationships exist among those data.
• DBA uses this level
• Hides details of physical storage structures
• External View or View level
• The highest level of abstraction describes only part of the entire
database.
• Application programs
• Describe part of the database that a particular user group is
interested in
✓ Hides rest of database from that user group
✓ hide information (e.g., salary) for security purposes.
30
Data Independence
• Data Independence is defined as a property of
DBMS that helps you to change the Database
schema at one level of a database system
without requiring to change the schema at the
next higher level.
• Data independence helps you to keep data
separated from all programs that make use of
it.
• In DBMS there are two types of data
independence
• Physical data independence
• Logical data independence.
31
Data Independence
• Physical Data Independence – the ability to modify the
physical schema without changing the logical schema
• Applications depend on the logical schema
• In general, the interfaces between the various levels and
components should be well defined so that changes in some parts
do not seriously influence others.
• Numeric(7) to numeric(10)
• Logical Data Independence- the ability to modify the
logical schema without having to change external schema or
application programs.
S# Sname Grade
32
Logical Data Independence vs Physical Data Independence
33
Instances and Schemas
• Databases change over time as information is
inserted and deleted.
• The collection of information stored in the
database at a particular moment is called an
instance of the database.
• The overall design of the database is called the
database schema. Schemas are changed
infrequently, if at all.
• Database systems have several schemas,
partitioned according to the levels of abstraction.
• The physical schema describes the database
design at the physical level, while the logical
schema describes the database design at the
logical level.
• A database may also have several schemas at the
view level, sometimes called subschemas, that
describe different views of the database.
34
Data Models
35
Data Models
• A collection of conceptual tools for describing data,
data relationships, data semantics, and consistency
constraint.
• A data model provides a way to describe the design
at physical, logical & view level.
• Various data models are:
1. The entity- relationship model
2. The object oriented model
3. Relational model
4. Network model and
5. Hierarchical model
36
Hierarchical database model
In the hierarchical model, data is organized as an inverted
tree. Each entity has only one parent but can have several
children. At the top of the hierarchy, there is one entity,
which is called the root.
40
Object Oriented Model
• This is extended ER model
• Having notion of encapsulation, methods (functions) &
object identity.
• Object Relational Data Models
• Extend the relational data model by including object
orientation and constructs to deal with added data types.
• Allow attributes of tuples to have complex types, including
non-atomic values such as nested relations.
• Preserve relational foundations, in particular the declarative
access to data, while extending modeling power.
• Provide upward compatibility with existing relational
languages.
41
Database languages
42
Data Definition Language
44
Data Control Language
45
Transaction Control Language
47
Two – tier Architecture
• Application is partitioned into
two components:
• Server: runs query language client
statements
• Clients: provide user interface and
local processing
• JDBC & ODBC are used for
interaction between the client
Server
and the server.
48
2-tier DBMS Architecture
49
Two-Tier Architecture
• The two-tier is based on Client Server architecture. The two-tier
architecture is like client server application. The direct communication
takes place between client and server. There is no intermediate between
client and server. Because of tight coupling a 2 tiered application will run
faster.
50
• The above figure shows the architecture of two-tier. Here the direct communication between client
and server, there is no intermediate between client and server.
• Let’s take a look of real life example of Railway Reservation two-tier architecture:
• Let’s consider that first Person is making Railway Reservation for Mumbai to Delhi by Mumbai
Express at Counter No. 1 and at same time second Person is also try to make Railway reservation of
Mumbai to Delhi from Counter No. 2
• If staff from Counter No. 1 is searching for availability into system & at the same staff from Counter
No. 2 is also looking for availability of ticket for same day then in this case there is might be good
change of confusion and chaos occurs. There might be chance of lock the Railway reservation that
reserves the first.
• But reservations can be making anywhere from the India, then how it is handled?
• So here if there is difference of micro seconds for making reservation by staff from Counter No. 1 & 2
then second request is added into queue. So in this case the Staff is entering data to Client
Application and reservation request is sent to the database. The database sends back the
information/data to the client.
• In this application the Staff user is an end user who is using Railway reservation application software.
He gives inputs to the application software and it sends requests to Server. So here both Database
and Server are incorporated with each other, so this technology is called as “Client-Server
Technology“.
• The Two-tier architecture is divided into two parts:
• 1) Client Application (Client Tier)
2) Database (Data Tier)
• On client application side the code is written for saving the data in the SQL server database. Client
sends the request to server and it process the request & send back with data. The main problem of
two tier architecture is the server cannot respond multiple request same time, as a result it cause
51 a
data integrity issue.
• Advantages:
• Easy to maintain and modification is bit easy
• Communication is faster
• Disadvantages:
• In two tier architecture application performance will
be degrade upon increasing the users.
• Cost-ineffective
52
3-tier DBMS Architecture
3-tier DBMS architecture is the most commonly used
architecture for web applications.
Cont..
53
Three tier Architecture
• Client: merely a user interface client
(form interface) but no direct DB
calls, client
55
Three-Tier Architecture
56
• Advantages
• High performance, lightweight persistent objects
• Scalability – Each tier can scale horizontally
• Performance – Because the Presentation tier can cache requests,
network utilization is minimized, and the load is reduced on the
Application and Data tiers.
• High degree of flexibility in deployment platform and configuration
• Better Re-use
• Improve Data Integrity
• Improved Security – Client is not direct access to database.
• Easy to maintain and modification is bit easy, won’t affect other
modules
• In three tier architecture application performance is good.
•
• Disadvantages
• Increase Complexity/Effort
57
Database Architecture
Overall database mgmt. structure
58
Use Write Use Use
Query Processor
Storage Manager
61
Storage Manager
• Provide interface between low level data in
database and application program.
• Components:
• Authorization & integrity Manager: define role and
responsibility for users, and provide Integrity checks.
• Transaction manager: ensure DB consistency in
concurrent access
• File Manager: manage allocation of disk space and Data
structure used for storing data
• Buffer Manager: decide what data to cache
62
Disk Storage
• Data Files: which stores database itself
• Data Dictionary: stores metadata about the
structure of the database
• Indices: provide fast access to data items
63
Query Processor
• DDL interpreter: which interprets DDL statements
and records the definitions in the data dictionary
• DML Compiler: translate DML statements to
evaluation plan. Also perform query optimization.
(pick the lowest cost evaluation plan from among
the alternatives)
• Query Evaluation Engine: executes low level
instructions generated by DML compiler.
64