Dbms-Unit-1 21012022
Dbms-Unit-1 21012022
Systems
Unit-1
Introduction to DBMS
Computer Civil
Database management
system can remove such Same data is stored at
data redundancy by storing four different places.
data centrally.
Electrical Mechanical
Remove data inconsistency
Computer Civil
Electrical Mechanical
Data Isolation
Emp_Name Address Mob Subject
Prof. Ajay Shah Rajkot 1234 CPU
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
Should be between 0 to 10
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
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
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
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
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.
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
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
Data-Definition Language
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
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
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
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
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.