Unit-1 DBMS Notes
Unit-1 DBMS Notes
▪ Developed in 1980’s
A File-Based System
Limitations of File-Based Approach
Efforts for query answering:
• What is the average grade for BE students?
• List the activities for all students enrolled in 2019.
• Which personnel are students as well as staff?
Other limitations:
• Data redundancy:Duplication of data
• Data Isolation:Data dependency
• Data inconsistency:No data updation at all places
• Data Security:
• Slow development, high maintenance and fixed queries
Purpose of Database Systems
In the early days, database applications were built
directly on top of file systems, which leads to:
• Data redundancy and inconsistency: data is stored in multiple file
formats resulting induplication of information in different files
• Difficulty in accessing data
– Need to write a new program to carry out each new task
• Data isolation
– Multiple files and formats
• Integrity problems
– Integrity constraints (e.g., account balance > 0) become
“buried” in program code rather than being stated explicitly
– Hard to add new constraints or change existing ones
Purpose of Database Systems (Cont.)
• Atomicity of updates
– Failures may leave database in an inconsistent state with partial updates
carried out
– Example: Transfer of funds from one account to another should either
complete or not happen at all
• Concurrent access by multiple users
– Concurrent access needed for performance
– Uncontrolled concurrent accesses can lead to inconsistencies
• Ex: Two people reading a balance (say 100) and updating it by
withdrawing money (say 50 each) at the same time
• Security problems
– Hard to provide user access to some, but not all, data
• No redundant data
• Data Consistency and Integrity
• Data Security
• Privacy
• Easy access to data
• Easy recovery
• Flexible
Database Applications Examples
• Enterprise Information
– Sales: customers, products, purchases
– Accounting: payments, receipts, assets
– Human Resources: Information about employees, salaries, payroll taxes.
• Banking and finance
– customer information, accounts, loans, and banking transactions.
– Credit card transactions
– Finance: sales and purchases of financial instruments (e.g., stocks and bonds; storing real-time market
data
• Airlines: reservations, schedules
• Telecommunication: records of calls, texts, and data usage, generating monthly bills, maintaining balances
on prepaid calling cards
• Universities: registration, grades, students record
Application of Database.....
DDL:
The users of the database normally don't interact with the data
dictionary, it is only handled by the database administrators.
The data dictionary holds information about the following −
• Update
• Retrieve
• Organise
• Protect
their data.
Architecture of Database Management System :
• A database system is partitioned into modules that deal
with each of the responsibilities of the overall system.
• The functional components of a database system can be
divided into
• The Disk Storage,
• The storage manager,
• The query processor component,
• The Users and its interaction.
Architecture
of Database
Management
System
1. The disk Storage
• The disk storage or physical storage is use for storing the data. In many big
enterprises,the database range in size from hundred of gigabytes to
terabytes of data. The main memory is not so largeer that it holds that much
information and data. so we needed a larger disk storage for the database.
• 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 buffer manager is a critical part of the
database system, since it enables the database to handle data sizes that are much larger
than the size of main memory.
3. Query Processor
• The query processor components include:
– DDL interpreter -- interprets DDL statements and records the
definitions in the data dictionary.
– DML compiler -- translates DML statements in a query language
into an evaluation plan consisting of low-level instructions that the
query evaluation engine understands.
• The DML compiler performs query optimization; that is, it picks
the lowest cost evaluation plan from among the various
alternatives.
– Query evaluation engine -- executes low-level instructions
generated by the DML compiler.
Query Processing
1. Parsing and translation
2. Optimization
3. Evaluation
Transaction Management
• A transaction is a collection of operations that performs a single logical function in a
database application
• DBMS is good for the large system but, the traditional file system is good for a small system
having a small number of items.
• DBMS required lots of effort for designing but, the traditional file system is very low design
efforts.
• DBMS is highly secured but, the traditional file system is not secure.
• DBMS is data sharable but, the traditional file system is isolated data sharable.
• DBMS is flexible but, the traditional file system has a lack of flexibility and has many limitations.
• DBMS has no integrity but, the traditional file system has an integrity problem.
• DBMS has a complex backup system but, the traditional file system has a simple backup system.
• DBMS removed data redundancy but, the traditional file system has data redundancy.
Instances and Schemas
• A collection of information stored in the database at a particular
moment is called an instance of database. And the overall
design/structure of database is called the database schema.
External/Conceptual
mapping
Conceptual/Internal
mapping
Three Level Schema Architecture of Database.....
1. External level:- It is also called view level. The reason this level is called “view” is
because several users can view their desired data from this level which is internally
fetched from database with the help of conceptual and internal level mapping.
The view schema describes the end user interaction with database systems.
2. Conceptual level:-It is also called logical level. The whole design of the database such as
relationship among data, schema of data etc. are described in this level.
3. Internal level:- This level is also known as physical level. This level describes how the
data is actually stored in the storage devices. This level is also responsible for allocating
space to the data. This is the lowest level of the architecture.
The physical level is used to describe complex low-level data structures in detail.
Database Applications
Database applications are usually partitioned into three parts
• One-tier architecture --Sinle layer architecture,in which database
and application resides in single machine/system.use only DBA
while designing a database.
1-tier architecture
Two-tier architecture Three-tier Architectures
Client Machine Client Machine
USER USER
Client Application
Application Program Layer Application Program
Network Network
Business Layer
Application Server
Database Server
Database Server
Data Server Layer
• Schema definition
• Storage structure and access-method definition
• Schema and physical-organization modification
• Granting of authorization for data access
• Routine maintenance
• Periodically backing up the database
• Ensuring that enough free disk space is available for normal operations, and upgrading disk
space as required
• Monitoring jobs running on the database
Functions of a DBA.............
• 1. Schema Definition:
• The DBA definition the logical Schema of the database.A Schema refers to the
overall logical structure of the database.
• According to this schema, database will be developed to store required data for an
organization.
• 2. Storage Structure and Access Method Definition:
• The DBA decides how the data is to be represented in the stored database.
• 3. Assisting Application Programmers:
• The DBA provides assistance to application programmers to develop application
programs.
• 4. Physical Organization Modification:
• The DBA modifies the physical organization of the database to reflext the changing
needs of the organization or to improve performance.
Functions of a DBA ...
• 5. Approving Data Access:
• The DBA determines which user needs access to which part of the database.
• According to this,various types of authorizations are granted to different users.
• 6. Monitoring Performance:
• The DBA monitors performance of the system.The DBA ensures that better
performance is maintained by making changes in physical or logical schema if
required.
• 7. Backup and Recovery:
• Database should not be lost or damaged.
• The DBA ensures this periodically backing up the database on magnetic tapes or
remote servers.
• In case of failure, such as virus attack database is recovered from this backup.
Data Models
a) Entity Relationship
b) Object Oriented
c) Semantic
d) Functional
a. Entity-Relationship Data Model
Disadvantages of ER Model
• No industry standard for notation: There is no industry standard for developing an ER model. So
one developer might use notations which are not understood by other developers.
• Hidden information: Some information might be lost or hidden in the ER model. As it is a high-
level view so there are chances that some details of information might be hidden.
b. Object-Oriented Data Model
• The real-world problems are more closely represented through the
object-oriented data model. In this model, both the data and
relationship are present in a single structure known as an object.
• We can store audio, video, images, etc in the database which was not
possible in the relational model .
• In this model, two are more objects are connected through links. We
use this link to relate one object to other objects.
Object-Oriented Data Model
Object-Oriented Data Model........
• This model was introduced by E.F Codd in 1970, and since then it has been
the most widely used database model, infact, we can say the only database
model used around the world.
• The basic structure of data in the relational model is tables. All the information
• This was the most widely used database model, before Relational Model
was introduced.
NETWORK DATA MODEL....
NETWORK DATA MODEL
Advantages of Network Model
• The data can be accessed faster as compared to the hierarchical model. This is because
the data is more related in the network model and there can be more than one path to
reach a particular node. So the data can be accessed in many ways.
• As more and more relationships need to be handled the system might get complex. So, a
user must be having detailed knowledge of the model to work with the model.
• In this model, a child node will only have a single parent node.
• In hierarchical model, data is organised into tree-like structure with one one-to-
many relationship between two different types of data, for example, one
department can have many courses, many professors and of-course many
students.
Hierarchical Data Model
Hierarchical Data Model
Advantages of Hierarchical Model
• It is very simple and fast to traverse through a tree-like structure.
• As it does not support more than one parent of the child node so if we
have some complex relationship where a child node needs to have
two parent node then that can't be represented using this model.
• If a parent node is deleted then the child node is automatically
deleted.
3. Physical Data Models
• It describe how data is stored in the computer, representing information such
as record structures, record ordering and access paths.
• tto describe the behaviour of data at disk level, the way is data and data
relationships are maintained while storing them on the disk.
• Decide the way the DBMS is gi=oing to use sec0ndary storage devoice for
storing and accessing database.
a.Unifying model
• Key Attribute –
The attribute which uniquely identifies each entity in the entity set is called key attribute. For example,
Roll_No will be unique for each student.
• Representation:- oval with underlying lines.
• Multivalued Attribute –
An attribute consisting more than one value for a given entity. For example, Phone_No (can be more
than one for a given student)
• Representation:- double oval
• Composite Attribute –
An attribute composed of many other attribute is called as composite attribute. For example, Address
attribute of student Entity type consists of Street, City, State, and Country.
• Representation:- oval comprising of ovals
• Derived Attribute –
An attribute which can be derived from other attributes of the entity type is known as derived attribute. e.g.;
Age (can be derived from DOB).
• Representation:- dashed oval.
• The complete entity type Student with its attributes can be represented as:
Relationship Type and Relationship Set:
• A relationship type represents the association between entity types. For example, 'Enrolled
in’ is a relationship type that exists between entity type Student and Course.
• represented :- diamond and connecting the entities with lines.
• A set of relationships of same type is known as relationship set. The following relationship set
depicts S1 is enrolled in C2, S2 is enrolled in C1 and S3 is enrolled in C3.
Degree of a relationship set
• The number of different entity sets participating in a relationship set is called as degree of a
relationship set.
• Unary Relationship –
When there is only ONE entity set participating in a relation, the relationship is called as
unary relationship. For example, one person is married to only one person.
• Binary Relationship –
When there are TWO entities set participating in a relation, the relationship is called as
binary relationship.For example, Student is enrolled in Course.
Cardinality:
• The number of times an entity of an entity set participates in a relationship set is known as cardinality.
Cardinality can be of different types:
• One to one – When each entity in each entity set can take part only once in the relationship, the
cardinality is one to one. Let us assume that a male can marry to one female and a female can married to
one male. So the relationship will be one to one.
• Many to one – When entities in one entity set can take part only once in the relationship set and
entities in other entity set can take part more than once in the relationship set, cardinality is many to
one. Let us assume that a student can take only one course but one course can be taken by many students.
So the cardinality will be n to 1. It means that for one course there can be n students but for one student,
there will be only one course.
• Many to many – When entities in all entity sets can take part more than once in the
relationship cardinality is many to many. Let us assume that a student can take more than one course and
one course can be taken by many students. So the relationship will be many to many.
Weak Entity Type and Identifying Relationship:
• As discussed before, an entity type has a key attribute which uniquely identifies each entity in
the entity set. But there exists some entity type for which key attribute can’t be defined.
These are called Weak Entity type.
• For example, A company may store the information of dependants (Parents, Children, Spouse)
of an Employee. But the dependents don’t have existence without the employee. So
Dependent will be weak entity type and Employee will be Identifying Entity type for Dependant.
• A weak entity type is represented by a double rectangle. The participation of weak entity type
is always total. The relationship between weak entity type and its identifying strong entity type
is called identifying relationship and it is represented by double diamond.
ER examples
• The music database is designed to store details of a music collection, including the albums in the
collection, the artists who made them, the tracks on the albums, and when each track was last
played.
• The university database captures the details of students, courses, and grades for a university.
• The flight database stores an airline timetable of flight routes, times, and the plane types.
Converting ER Diagrams to Tables-
• Following rules are used for converting an ER diagram into the tables-
Rule-01: For Strong Entity Set With Only Simple Attributes-
• A strong entity set with only simple attributes will require only one table in relational model.
• Attributes of the table will be the attributes of the entity set.
• The primary key of the table will be the key attribute of the entity set.
•
• Rule-02: For Strong Entity Set With Composite Attributes-
• A strong entity set with any number of composite attributes will require only one table in
relational model.
• While conversion, simple attributes of the composite attributes are taken into account and
not the composite attribute itself.
• Rule-03: For Strong Entity Set With Multi Valued Attributes-
• A strong entity set with any number of multi valued attributes will require two tables in
relational model.
• One table will contain all the simple attributes with the primary key.
• Other table will contain the primary key and all the multi valued attributes.
• Rule-04: Translating Relationship Set into a Table-
• A relationship set will require one table in the relational model.
• Attributes of the table are-
• Primary key attributes of the participating entity sets
• Its own descriptive attributes if any.
• Set of non-descriptive attributes will be the primary key.
• NOTE-
• If we consider the overall ER diagram, three tables will be required in relational model-
• One table for the entity set “Employee”
• One table for the entity set “Department”
• One table for the relationship set “Works in”
• Rule-05: For Binary Relationships With Cardinality Ratios-
• The following four cases are possible-
• Case-01: Binary relationship with cardinality ratio m:n
• Case-02: Binary relationship with cardinality ratio 1:n
• Case-03: Binary relationship with cardinality ratio m:1
• Case-04: Binary relationship with cardinality ratio 1:1
• Case-01: For Binary Relationship With Cardinality Ratio m:n
• Here, three tables will be required-
• A ( a1 , a2 )
• R ( a1 , b1 )
• B ( b1 , b2 )