0% found this document useful (0 votes)
24 views71 pages

Dbms-Unit-1 21012022

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views71 pages

Dbms-Unit-1 21012022

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 71

Database Management

Systems

Unit-1
Introduction to DBMS

SREENIDHI INSTITUTE OF SCIENCE & TECHNOLOGYY


YAMNAMPET, GHATKESAR 501
Dr H balaji Dept 301, RANGA REDDY DIST.
Of CSE 1
Topics to be covered Unit-I
• Data Vs Information
• Data base System Applications
• data base System VS file System
• View of Data
• Data Abstraction
• Instances and Schemas
• data Models
• Database Languages
• database Access for applications Programs
• data base Users and Administrator
• Transaction Management
Topics to be covered UNIT-I Contd.
• Transaction Management
• data base System Structure
• Storage Manager the Query Processor
• Data base design and ER diagrams
• Entities, Attributes and Entity sets
Relationships and
• Relationship sets Additional features of ER
Model
• Concept Design with the ER Model –Data
• Modeling checklist
• Application- ER diagram for a college
What is Database Management System (DBMS)?
 Data - Fact that can be recorded or stored
• e.g. Person Name, Age, Gender and Weight etc.
 Database - Collection of logically related data
• e.g. Books Database in Library, Student Database in University etc.
 Management - Manipulation, Searching and Security of data
• e.g. Viewing result in GTU website, Searching exam papers in GTU website
 System - Programs or tools used to manage database
• e.g. SQL Server Studio Express, Oracle
 DBMS - A Database Management System is a software for
creating and managing databases.
 Database Management System (DBMS) is a software designed to
define, manipulate, retrieve and manage data in a database.
• e.g. MS SQL Server, Oracle, My SQL, SQLite, MongoDB etc.
Applications
of
DBMS
Applications of DBMS
 DBMS is a computerized record-keeping system.
 DBMS is required where ever data need to be stored.
1. E-Commerce (Flikart, Amazon, Shopclues, eBay etc.)
2. Online Television Streaming (Hotstar, Amazon Prime etc.)
3. Social Media (WhatsApp, Facebook, Twitter, LinkedIn etc.)
4. Banking & Insurance
5. Airline & Railway
6. Universities and Colleges/Schools
7. Human Resource Department
8. Hospitals and Medical Stores
9. Government Organizations
Exercise
Exercise

1. Write down any five applications of DBMS other than the


previous slide.
Advantages
of
DBMS
Reduce data redundancy (duplication)

Computer Civil

Emp_Name Address Mob Subject Emp_Name Address Mob Subject


Prof. Ajay Shah Rajkot 1234 CPU Prof. Ajay Shah Rajkot 1234 CPU

Database management
system can remove such Same data is stored at
data redundancy by storing four different places.
data centrally.

Emp_Name Address Mob Subject Emp_Name Address Mob Subject


Prof. Ajay Shah Rajkot 1234 CPU Prof. Ajay Shah Rajkot 1234 CPU

Electrical Mechanical
Remove data inconsistency

Computer Civil

Emp_Name Address Mob Subject Emp_Name Address Mob Subject


Prof. Ajay Shah Rajkot 1234
6789 CPU Prof. Ajay Shah Rajkot 1234 CPU

Same data having


Database management different state (values)
system can keep data in
consistent state.
Mobile no is changed

Emp_Name Address Mob Subject Emp_Name Address Mob Subject


Prof. Ajay Shah Rajkot 6789 CPU
1234 Prof. Ajay Shah Rajkot 1234 CPU

Electrical Mechanical
Data Isolation
Emp_Name Address Mob Subject
Prof. Ajay Shah Rajkot 1234 CPU

Emp_Name Salary Load


Prof. Ajay Shah 50000 20

Emp_Name Teaching Knowledge Rating


Prof. Ajay Shah Good V. Good 9

• Data are scattered in various files


• Files may be in different formats
• Difficult to retrieve the appropriate data
DBMS allow us to access (retrieve) appropriate data
easily.
Guaranteed Atomicity
• Either transaction execute 0% or 100%.

Sum of both account


before transfer is
3000

Person A Person B
Account A Transfer 500 Account B
Bal : 2000 Bal : 1000
Step 1 : Debit 500 from Account A
Step 2 : Credit 500 into Account B
Transactio Sum of both
n is failed Sum of both account account is 2500
after transfer is 3000 so inconsistent
Allow to implement integrity constraints
Emp_Name Address Mobile Subject
Prof. Ajay Shah Rajkot 9825598255 CPU
Should contain exact 10
digits

Stu_Name Branch Backlogs SPI


Nirav Patel C.E. 8 2.5

Should be between 0 to 10

DBMS allows us to implement such business rules in our


database.
Sharing of data among multiple users
Want to
access
Computer Civil

Emp_Name Address Mob Subject Emp_Name Address Mob Subject


Prof. Ajay Shah Rajkot 1234 CPU Prof. Ajay Shah Rajkot 1234 CPU

Database management system


allows more than one user to
access same data
Want to
access simultaneously.

Emp_Name Address Mob Subject Emp_Name Address Mob Subject


Prof. Ajay Shah Rajkot 1234 CPU Prof. Ajay Shah Rajkot 1234 CPU

Electrical Mechanical
Restricting unauthorized access to data
Emp_Name Address Mob Subject Wants to
access Faculty
Prof. Ajay Shah Rajkot 1234 CPU
of other
college
Emp_Name Salary Load
Prof. Ajay Shah 50000 20 Wants to
access Darshan
Emp_Name Teaching Knowledge Rating Faculty
Prof. Ajay Shah Good V. Good 9

DBMS prevents unauthorized user to access


data.
Providing backup and recovery services

Provides facilities to backup and restore the database in case


of failure.
Advantages of DBMS (Summary)
1. Reduce data redundancy (duplication)
• Avoids unnecessary duplication of data by storing data centrally.
2. Remove data inconsistency
• By eliminating redundancy, data inconsistency can be removed.
3. Data isolation
• A user can easily retrieve proper data as per his/her requirement.
4. Guaranteed atomicity
• Either transaction executes 0% or 100%.
Advantages of DBMS (Summary)
5. Allow implementing integrity constraints
• Business rules can be implemented such as do not allow to store amount
less than Rs. 0 in balance.
6. Sharing of data among multiple users
• More than one users can access same data at the same time.
7. Restricting unauthorized access to data
• A user can only access data which is authorized to him/her.
8. Providing backup and recovery services
• Can take a regular auto or manual backup and use it to restore the
database if it corrupts.
Basic Terms
 Data
• Data is raw, unorganized facts that need to be processed.
• Example: Marks of students
• Student_1 = 50/100, Student_2 = 25/100.

 Information
• When data is processed, organized, structured or presented in a given
context so as to make it useful, it is called information.
• Example: Result of students (Pass or Fail)
• Student_1 = Pass, Student_2 = Fail.
Basic Terms (cont…)
 Metadata
• Metadata is data about data.
• Data such as table name, column name, data type, authorized user and
user access privileges for any table is called metadata for that table.
Emp_Name Address Mob Subject
Prof. Ajay Shah Rajkot 1234 CPU
Prof. Om Patel Rajkot 6789 DBMS

• Metadata of above table is:


• Table name such as Faculty
• Column name such as Emp_Name, Address, Mob, Subject
• Datatype such as Varchar, Decimal
• Access privileges such as Read, Write (Update)
Basic Terms (cont…)
 Data dictionary
• A data dictionary is an information repository which contains metadata.
• Table Name – Faculty
• Column Name – EmpName, Address, Mob, Subject,
Salary
• Datatype – Varchar, Decimal
• Access Privileges – Read, Write (Update)

 Data warehouse
• A data warehouse is an information repository which stores data.
Emp_Name Address Mob Subject
Prof. Ajay Shah Rajkot 1234 CPU
Prof. Om Patel Rajkot 6789 DBMS
Basic Terms (cont…)
 Field
• A field is a character or group of characters that have a specific meaning.
• E.g, the value of Emp_Name, Address, Mob etc are all fields for Faculty
table.
Fields
Emp_Name Address Mob Subject
Prof. Ajay Shah Rajkot 1234 CPU Prof. Ajay Shah
Prof. Om Patel Rajkot 6789 DBMS Rajkot

 Record / Tuple
• A record is a collection of logically related fields.
• E.g, the collection of fields (Emp_Name, Address, Mob, Subject & Salary)
forms a record for the Faculty.
Record /
Prof. Ajay Shah Rajkot 1234 CPU
Tuple
Exercise
Exercise

1. How many fields and records are there in the following table?
Emp_Name Address Mob Subject
Prof. Ajay Shah Rajkot 1234 CPU
Prof. Om Patel Rajkot 6789 DBMS
Prof. Jay Mehta Baroda 4567 DS
Prof. Neel Jha Surat 7890 CPP
Exercise
Exercise

1. Why data dictionary and data warehouse are stored in the


different places?
Exercise
Exercise

View of Data

1. Data abstraction
2. Data independence
3. Instance and schema
Exercise
Exercise

Data
Data Abstraction
Abstraction

Data
Data abstraction
abstraction isis hiding
hiding the
the complex
complex data
data structure
structure in
in order
order toto simplify
simplify the
the user’s
user’s
interface
interface of
of the
the system.
system. ItIt isis done
done because
because many
many ofof the
the users
users interacting
interacting with
with the
the
database
database system
system areare not
not that
that much
much computer
computer trained
trained to
to understand
understand thethe complex
complex data
data
structures
structures of
of the
the database
database system.
system.
To
To achieve
achieve data
data abstraction,
abstraction, we we will
will discuss
discuss aa
Three-Schema
Three-Schema architecture
architecture which which abstracts
abstracts the
the database
database atat three
three levels
levels discussed
discussed below:
below:
Exercise
Exercise

Three-Schema
Three-Schema Architecture:
Architecture:
The
The main
main objective
objective ofof this
this architecture
architecture isis to
to have
have an
an effective
effective separation
separation between
between the
the user
user
interface
interface and
and the
the physical
physical database.
database. So,So, the
the user
user never
never has
has to
to be
be concerned
concerned regarding
regarding the
the
internal
internal storage
storage ofof the
the database
database and
and itit has
has aa simplified
simplified interaction
interaction with
with the
the database
database
system.
system.
The
The three-schema
three-schema architecture
architecture defines
defines thethe view
view of
of data
data at
at three
three levels:
levels:
Physical
Physical level
level (internal
(internal level)
level)
Logical
Logical level
level (conceptual
(conceptual level)
level)
View
View level
level (external
(external level)
level)
3 Levels
ANSI SPARC
Database System
3 Levels ANSI SPARC Database System

User 1 User 2 User 3


How data are viewed View
View 1 View 2 View 3
by each users? Level

What data are stored and Conceptual Logical


What relationships exist? Level Level

How the data are actually Internal Physical


stored on storage devices? Level Level

Database
Internal level (Physical level)
 It describes how a data is stored on the storage device.
 Deals with physical storage of data.
• Structure of records on disk - files, pages, blocks
• Indexes and ordering of records
 Internal view is described by the internal schema.
Conceptual level (Logical level)
 What data are stored and what relationships exist among those
data?
 It hides low level complexities of physical storage.
 For Example, STUDENT database may contain STUDENT and
COURSE tables which will be visible to users but users are unaware
about their storage.
 Database administrator works at this level to determine what data
to keep in the database.
External level (View level)
 It describes only part of the entire database that an end user
concern or How data are viewed by each user.
 End users need to access only part of the database rather than the
entire database.
 Different user needs different views of the database, so there can
be many views in a view level abstraction of the database.
 Used by end users and application programmers.
3 Levels ANSI SPARC Database System: Example
We are storing student information in
a student table.
User 1 User 2 User 3
User just interact with system with the
help of GUI. View 1 View 2 View 3
Users are not aware of how and what
the data is stored.

Records can be described as fields and


Conceptual
attributes along with their data types,
Level
their relationship among each other
can be logically implemented.
Programmers generally work at this
level. Internal
Records can be described as blocks of Level
storage (bytes, gigabytes, terabytes
etc.) in memory. These details are often
hidden from the programmers.
Database
Data Abstraction in DBMS
 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.
Mapping
Want to access some
data
User 1 User 2 User 3
View
View 1 View 2 View 3
Level

Conceptual Logical
Level Level

Process of transforming
requests and results Internal Physical
between the three levels Level Level
is called mapping. Result

Database
Data Independence
User 1 User 2 User 3
View
View 1 View 2 View 3
Level

Conceptual Logical
Level Level

Ability to modify a schema


definition in one level Internal Physical
without affecting a schema Level Level
definition in the next
higher level.
Database
Types of Data Independence
1. Physical Data Independence
2. Logical Data Independence
Physical Data Independence
 Physical Data Independence is the ability to modify the physical
schema without requiring any change in logical (conceptual)
schema and application programs.
 Modifications at the internal levels are occasionally necessary to
improve performance.
 Possible modifications at internal levels are changes in file
structures, compression techniques, hashing algorithms, storage
devices, etc.
Logical Data Independence
 Logical data independence is the ability to modify the conceptual
schema without requiring any change in application programs.
 Modification at the logical levels is necessary whenever the logical
structure of the database is changed.
 Application programs are heavily dependent on logical structures
of the data they access. So any change in logical structure also
requires programs to change.
Instance and Schema
• Instance • Schema
– The collection of – The overall design of
information stored in database is called
the database at database schema.
particular moment is – Schemas are changed
called instance. rarely.
– Instances are changed
frequently.

Emp_Name Salary Schema


Char(10) Int
Prof. Ajay Shah 15000
Instance
Prof. Om Patel 10000
What is a Database Models?
 A database model is a type of data model that defines the logical
structure of a database.
 It determine how data can be stored, accessed and updated in a
database management system
 The most popular example of a database model is the relational
model, which uses a table-based format.
Type of Database Models
Hierarchical Model
 The hierarchical model organizes data into a tree-like structure,
where each record has a single parent or root.
Department

Student Professor
 The hierarchy starts from the Root data, and expands like a tree,
adding child nodes to the parent nodes.
 In hierarchical model, data is organised into tree-like structure
with one-to-many relationship between two different types of
data, for example, one department can have many professors
and many students.
Network Model
 This is an extension of the hierarchical model, allowing many-to-
many relationships in a tree-like structure that allows multiple
parents.
A

B C

D E F
Entity-relationship Model
 In this database model, relationships are created by dividing
object of interest into entity and its characteristics into
attributes.
Attribute
s
RollNo Name BookNo Name
Relationship

Student Issue Book

Branch Sem Entities Author Price


Relational Model
 In this model, data is organised in two-dimensional tables and
the relationship is maintained by storing a common attribute.
Rno Student_Name Age SubjectID Subject_Name Teacher
1 Raj 21 1 DBMS Patel
2 Meet 22 2 DS Shah

Rno SubjectID Marks


1 1 98
1 2 95
2 1 95
2 2 90
Object-oriented database model
 This data model is another method of representing real world
objects.
 It considers each object in the world as objects and isolates it
from each other.
 It groups its related functionalities together and allows inheriting
its functionality to other related sub-groups.
Database Languages

A database system provides a data definition language to


specify the database schema, a data manipulation language
to express database queries and updates and a data control
language to control a database

In practice these are not separate languages; instead they


simply form parts of a single database language, such as the
widely used SQL language

Data-Definition Language

This supports the creation, deletion, and modification of


definitions for tables and views
The following statement in the SQL language defines the
account table:

create table account


(account-number char(10),
Balance number(5))

Execution of the above DDL statement creates the account


table

In addition, it updates a special set of tables called the


data dictionary or data directory

A data dictionary contains metadata—that is, data about


data
The schema of a table is an example of metadata
A database system consults the data dictionary before
reading or modifying actual data

Data-Manipulation Language
Data manipulation is
The retrieval of information stored in the database
The insertion of new information into the database
The deletion of information from the database
The modification of information stored in the database
A data-manipulation language (DML) is a language
that enables users to access or manipulate data
There are basically two types:
Procedural DMLs require a user to specify what data are
needed and how to get those data
Declarative DMLs (also referred to as nonprocedural
DMLs) require a user to specify what data are needed
without specifying how to get those data

This query in the SQL language finds the name of the


customer whose customer-id is 192-83-7465:
select customer-name
from customer
where customer-id = '192-83-7465'

Data-Control Language
This subset of SQL controls a database, including
administrative privileges and saving data
Database Access from Application Programs
Application programs are programs that are used to
interact with the database
Application programs are usually written in a host
language, such as Cobol, C, C++, or Java
Examples in a banking system are programs that generate
payroll checks, debit accounts, credit accounts, or transfer
funds between accounts
To access the database, DML statements need to be
executed from the host language
There are two ways to do this:
By providing an application program interface (set of
procedures) that can be used to send DML and DDL
statements to the database, and retrieve the results
The Open Database Connectivity (ODBC) standard defined
by Microsoft for use with the C language is a commonly
used application program interface standard. The Java
Database Connectivity (JDBC) standard provides
corresponding features to the Java language

By extending the host language syntax to embed DML


calls within the host language program. Usually, a special
character prefaces DML calls, and a preprocessor, called the
DML precompiler, converts the DML statements to normal
procedure calls in the host language
Types
of
database users
Types of database users
1. Naive Users (End Users)
• Unsophisticated users who have zero knowledge of database system
• End user interacts to database via sophisticated software or tools
• e.g. Clerk in bank

2. Application Programmers
• Programmers who write software using tools such as Java, .Net, PHP etc…
• e.g. Software developers
Types of database users
3. Sophisticated Users
• Interact with database system without using an application program
• Use query tools like SQL
• e.g. Analyst

4. Specialized Users (DBA)


• User write specialized database applications program
• Use administration tools
• e.g. Database Administrator
Role of
DBA
(Database Administrator)
Role of DBA (Database Administrator)
1. Schema Definition
• DBA defines the logical schema of the database.
2. Storage Structure and Access Method Definition
• DBA decides how the data is to be represented in the database & how to
access it.
3. Defining Security and Integrity Constraints
• DBA decides on various security and integrity constraints.
4. Granting of Authorization for Data Access
• DBA determines which user needs access to which part of the database.
Role of DBA (Database Administrator)
5. Liaison with Users
• DBA provide necessary data to the user.
6. Assisting Application Programmer
• DBA provides assistance to application programmers to develop
application programs.
7. Monitoring Performance
• DBA ensures that better performance is maintained by making a change in
the physical or logical schema if required.
8. Backup and Recovery
• DBA backing up the database on some storage devices such as DVD, CD or
magnetic tape or remote servers and recover the system in case of
failures, such as flood or virus attack from this backup.
Transaction Management
Often, several operations on the database form a single
logical unit of work
An example is a funds transfer in which one account (say
A) is debited and another account (say B) is credited
Clearly, it is essential that either both the credit and debit
occur, or that neither occur
That is, the funds transfer must happen in its entirety or not
at all. This all-or-none requirement is called atomicity
In addition, it is essential that the execution of the funds
transfer preserve the consistency of the database. That is, the
value of the sum A + B must be preserved
This correctness requirement is called consistency
Finally, after the successful execution of a funds transfer,
the new values of accounts A and B must persist, despite the
possibility of system failure. This persistence requirement is
called durability
A transaction is a collection of operations that performs a
single logical function in a database application
We require that transactions do not violate any database-
consistency constraints
That is, if the database was consistent when a transaction
started, the database must be consistent when the
transaction successfully terminates
It is the programmer’s responsibility to define properly
the various transactions, so that each preserves the
consistency of the database
For example, the transaction to transfer funds from
account A to account B could be defined to be composed of
two separate programs: one that debits account A, and
another that credits account B
The execution of these two programs one after the other
will indeed preserve consistency
Ensuring the atomicity and durability properties is the
responsibility of the database system itself—specifically, of
the transaction-management component
If we are to ensure the atomicity property, a failed
transaction must have no effect on the state of the database.
Thus, the database must be restored to the state in which it
was before the transaction in question started executing
The database system must therefore perform failure
recovery, that is, detect system failures and restore the
database to the state that existed prior to the occurrence of
the failure
Finally, when several transactions update the database
concurrently, the consistency of data may no longer be
preserved, even though each individual transaction is
correct
It is the responsibility of the concurrency-control
manager to control the interaction among the concurrent
transactions, to ensure the consistency of the database
Note: each transaction possess ACID properties
Database
System
Architecture
Database System Architecture
Naive Application Sophisticated Database
user programmer user administrator
uses write uses uses

Application Application Query Administration


interfaces program tool tool

Translates
Interprets DML
DDL
Compiler DML DDL statements intoa
and linker queries interpreter statements
Deals
Executes low into
with level
low
set oflevel
tables
Application execution
instructions
instructions of
that
program DML compiler DDLcontaining
generatedand DML
the queryDML
metadata
by
object code and organizer statements
compiler.
evaluation engine
Query evaluation
engine Query processor understands

Buffer File Authorization and Transaction


manager manager integrity manager manager

Manages allocation
Storage manager
Fetches data from
of space on disk
disk storage to Preserves atomicity
Provides interface
memorystorage
for being Checks the authority
and controls
between low-level
used faster Indices Data dictionary of users to access
To provide Disk storage concurrency
data stored and
data and integrity
access to data items Data Statistical data To store statistical application program
To store user data Toinformation
store metadata constraints
about the or queries
data
The query processor is important because it helps the
database system simplify and facilitate access to data
The job of the database system is to translate queries at the
logical level, into an efficient sequence of operations at the
physical level

Storage Manager
A storage manager is a program module that provides the
interface between the low-level data stored in the database
and the application programs and queries submitted to the
system
The storage manager is responsible for the interaction with
the file manager
The raw data are stored on the disk
The storage manager is responsible for storing, retrieving,
and updating data in the database
The storage manager components include:
-Authorization and integrity manager, which tests for the
satisfaction of integrity constraints and checks the authority
of users to access data
-Transaction manager, which ensures that the database
remains in a consistent (correct) state despite system
failures, and that concurrent transaction executions proceed
without conflicting
-File manager, which manages the allocation of space on
disk storage and the data structures used to represent
information stored on disk
-Buffer manager, which is responsible for fetching data
from disk storage into main memory, and deciding what
data to cache in main memory
The storage manager implements several data structures as
part of the physical system implementation:
-Data files, which store the database itself
-Data dictionary, which stores metadata about the structure
of the database, in particular the schema of the database
-Indices, which provide fast access to data items that hold
particular values
The Query Processor
The query processor components include
-DDL interpreter, which interprets DDL statements and
records the definitions in the data dictionary
-DML compiler, which translates DML statements in a
query language into an evaluation plan consisting of low-
level instructions that the query evaluation engine
understands
--A query can usually be translated into any of a number of
alternative evaluation plans that all give the same result. The
DML compiler also performs query optimization, that is, it
picks the lowest cost evaluation plan from among the
alternatives
-Query evaluation engine, which executes low-level
instructions generated by the DML compiler
Questions asked in Previous paper
1. List and explain the advantages of DBMS.
2. Draw and explain 3 level architecture of DBMS.
3. List and explain categories of database users.
4. List and explain different tasks of DBA.
5. Explain DBMS architecture with block diagram.

You might also like