DBMS Unit-1
DBMS Unit-1
UNIT - I Database System Applications: A Historical Perspective, File Systems versus a DBMS, the Data Model, Levels of
Abstraction in a DBMS, Data Independence, Structure of a DBMS Introduction to Database Design: Database Design and
ER Diagrams, Entities, Attributes, and Entity Sets, Relationships and Relationship Sets, Additional Features of the ER
Model, Conceptual Design With the ER Model
- History of database
The database system has a long history over the period the technology for database storage and access method
has been changed.
1. During 1950’s, during this period, magnetic tapes are used as storage media. Data will be stored and
processed on the magnetic tapes by using sequential access. Therefore, processing speed is less during
1960’s to 1970’s.
2. During this period, the usage of hard disk has changed the scenario of data storage and data processing.
The hard disk will provide direct access of the data. Therefore, process will become faster.
3. During 1970’s, E.F. Codd introduced the relational model and therefore many relational DB has been
started.
4. During 1980’s, during this period, many relational DB such as oracle, SQL server, IBM DML has been
introduced in the market and many researchers start working on disturbed databases during 1990’s many
database vendors provided many distributed databases into market and the usage of SQL has provided a
convenient environment for the user to work with database system.
- View of Data
Database is a collection of large volumes of data the user does not always require the entire data from the
database. Therefore, it is the responsibility of the database to provide the required data to the user.
- Data abstraction
Data abstraction refers to the way of representing the essential features and hiding background details or
complexities from the user.
- Levels of abstraction
External View View View View
3. View Level
a. It is also known as external level.
b. It describes the part of entire database in the form of different views by different users.
- Instance
A database instance is a set of memory structure and background processes that access a set of database
files. The process can be shared by all users. The memory structure that are used to store most queried data
from database. This helps up to improve database performance by decreasing the amount of I/O performed
against data file.
- Schema/Scheme
The overall design of the database is known as the database schema. According to the levels of data
abstractions, there are 3 types of schemas available.
1. Physical Scheme 2. Logical Scheme 3. Sub Scheme
1. Physical Scheme: It describes the structure of data at physical level.
2. Logical Scheme: It describes the structure of data at logical level.
3. Sub Scheme: It describes different values of the users interacting with the database.
- Data independence
It is defined as the ability to modify data at one level without effecting at the next level. Data independence is
of 2 types
1. Physical data independence 2. Logical data independence
1. Physical Data Independence:
The ability to modify the physical structure at the physical level without effecting the next level (Logical
level) is known as Physical Data Independence.
2. Logical Data Independence:
The ability to modify the data at the logical level without effecting the next level (View level/External level)
is known as Logical Data Independence.
Note: Logical Data Independence is more difficult to implement than Physical Data Independence.
- Data Models
Data model is the way to represent the data within the database. Data model is a collection of conceptual tools
for describing:
1. For describing data
2. The relationship among data
3. Data semantic
4. The consistency constraints
Different data models are available. The classification of data model is shown below
Data
Model
Object based Record based Physical
data model Data Model data
E-R Model Hierarchical model
Network
Relational Unifying
Data model is mainly classified into 3 categories: Frame
Memory
1. Object based data model 2. Record based data model 3. Physical data model
1. Object based data model:
The object-based data model deals with the real-world object and relation among the objects. One of the
popular models to represent object-based model in E-R model.
E-R Model (Entity-Relationship):
The overall design of the database is represented graphically using entity-relationship diagram. The E-R
model shows entities, relations among entities in a diagrammatic fashion.
Ex: Entity: Student Entity: Class
Attributes: Roll no. Attributes: Room no.
Name No. of seats
Address Location
Section
Location
b. Network Model:
In this model, data and relation among data is represented using records and pointers. This model is
generally represented in graph like structure.
c. Relational Model:
i. It is the most popular data model used nowadays.
ii. It was developed in year 1970 by EF Codd.
iii. The main constraint is to represent the relational model is in the form of relation (Table).
iv. A relation is a combination of rows and columns.
v. Each relation represents a relational schema and relational instance.
Compiler
and DML DDL Interpreter
Queries
Linker Query
Processo
Application Queries r
DML Compiler
Program Evaluatio
Cod Engine
Object
e n
Authorizatio
File Buffer n
Manager Manager
and Integrity Storage
Manager Manage
Transition r
Manager
- Database Architecture:
The functional components of database architecture are categorised into 2 types:
1. Query processor 2. Storage manager
1. Query processor:
Query processor is a major component of database architecture. It includes the following components:
a. DML Compiler:
The DML compiler is used to compile the DML queries submitted by the user and generate low level
instruction understood by query evaluation engine.
b. DDL Interpreter:
The DDL interpreter will execute the DDL statements given by the user and store the result in a special
file called Data Dictionary.
c. Query evaluation engine:
The query evaluation will execute or evaluate low level instructions by DML compiler.
2. Storage manager:
The storage manager is a program module that acts as an interface between the query processor and low-
level data stored in the disk storage. It includes the following components:
a. Buffer manager:
The buffer manager is responsible for allocating temporary storage for the files.
b. File manager:
The file manager will take care of the files being stored in the database.
c. Authorization & Integrity manager:
This component is responsible for giving the authorization DAP (Data Access Permission) and
maintaining integrity of the database.
d. Transaction Manager:
It is responsible for managing the transaction within the database system. A transaction is a logical
unit of work done by the user.
Ex: Credit & debit operation in bank transaction.
The storage will maintain several data structures as part of physical storage implementation.
a. Indices (indexes): for faster retrieval of data.
b. Data files: It is a collection of data stored in the files.
c. Data Dictionary: It is a container for meta data.
d. Statistical data: It maintain the statistical information of database users.
- Database Design
The database design process consistence of the following steps:
1. Requirement Analysis (Data Gathering)
2. Conceptual Design (ER Model)
3. Logical Design (Relational Model)
4. Schema Refinement (Normalization Techniques)
5. Physical Database Design (index, clusters etc)
6. Database Tuning
7. Security Design (Authorization)
Emp Dep
t
Manage
d
E_Sal Desig Ph_No Budge
t
1. Key Constraints:
Consider the following ER – diagram given below
E_ID E_Name D_No D_Nam
e
discriminated
E_ID E_Name Nam key Ag
e e
E_Sal
(Overlap constrains)
(Covering constrains)
Is
Wage ID
Specialization
Generalization
s A
Hourly_Emps Contract_Emps
Hourly_worked Wage
s
a. Generalization:
Generalization is the process of finding some common properties of two sub classes having a
super class entity. In the above example, hourly emp, contract emp are generalized in emp.
b. Specialization:
The process of sub-dividing a super class entity into sub class entity is known as specialization.
In the above example, the super class entity emp is having sub class entities – hourly employee and
contract employee.
There are 2 constrains w.r.t generalization & specialization
i. Overlap Constraint:
The overlap constraint determines whether two subclass entities are allowed to have
common attributes of superclass.
ii. Covering Constraint:
Covering constraint determines whether the subclass entities include all the attributes of
super class.
5. Aggregation
E_No E_Name E_Desig
Emp
Monitor until
s
since
D_No D_Nam P_ID
e
Dept Sponsors Project Start
s data
budge
t
In ER diagram, we represent relationship as an association among 2 entities. Sometimes we want
to represent relationship among relationships. This will be done using a concept known as Aggregation.
In the above example, the relationship set sponsors is associated with the relationship monitors.
The aggregation is represented by considering the relationship set sponsored among 2 entities,
departments, projects as an entity set. It is shown with a dotted box in the diagram.
- Features of Aggregation
Aggregation is used to express relationship among relationship
6. Key constraints for ternary relationship
E_No E_Name D_No D_Nam
e
Emp Works in Dep
t
E_Sal Budge
t
from Location to
In the given ER diagram, an employee works in a department and in a single location. This
restriction for ternary relationship is represented with the key constraints using an arrow from employees
to work in relationship.
E_Desig Budge
t
from Duration to
2. Entity vs Relationship
Sometimes an object will be better expressed as an entity rather than a relation.
E_Name since budge D_No D_Nam
E_No t e
Is Location
A
since Manage budge
r t
3. Binary vs Ternary
Sometimes a non - binary relationship can be expressed using distinct binary relations. Consider the
givenER diagram policies with ternary relation.
E_Name D_Nam
E_No e Age
D_Nam
E_No E_Name e Age
Emp Dependen
t
4. Aggregation vs Ternary
Sometimes an ER diagram with aggregation can be best expressed as ternary relation.
E_Name
E_No
D_Nam E_Sal
Emp Amoun
D_No e P_ID t
Entity instance
Attributes
Domain of Attributes
The set of possible values that an attribute can take is called the domain of the attribute. For example, the
attribute day may take any value from the set {Monday, Tuesday ... Friday}. Hence this set can be termed as the
domain of the attribute day.
Key attribute
The attribute (or combination of attributes) which is unique for every entity instance is called key attribute.
E.g the employee_id of an employee, pan_card_number of a person etc.If the key attribute consists of two or
more attributes in combination, it is called a composite key.
In ER modeling, notation for key attribute is given below.
Simple attribute
Stored Attribute
An attribute which can be calculated or derived based on other attributes is a derived attribute.
Example for derived attribute : age of employee which can be calculated from date of birth and current date.
In ER modeling, notation for derived attribute is given below.
Relationships
However in ER Modeling, To connect a weak Entity with others, you should use a weak relationship notation as
given below
Degree of a Relationship
Degree of a relationship is the number of entity types involved. The n-ary relationship is the general form for
degree n. Special cases are unary, binary, and ternary ,where the degree is 1, 2, and 3, respectively.
Example for unary relationship : An employee ia a manager of another employee
Example for binary relationship : An employee works-for department.
Example for ternary relationship : customer purchase item from a shop keeper
Cardinality of a Relationship
Relationship cardinalities specify how many of each entity type is allowed. Relationships can have four possible
connectivities as given below.
1. One to one (1:1) relationship
2. One to many (1:N) relationship
3. Many to one (M:1) relationship
4. Many to many (M:N) relationship
The minimum and maximum values of this connectivity is called the cardinality of the relationship
Example for Cardinality – One-to-One (1:1)
One employee is assigned with only one parking space and one parking space is assigned to only one
employee. Hence it is a 1:1 relationship and cardinality is One-To-One (1:1)
In ER modeling, this can be mentioned using notations as given below
Example for Cardinality – One-to-Many (1:N)
One organization can have many employees , but one employee works in only one organization. Hence it is a
1:N relationship and cardinality is One-To-Many (1:N)
In ER modeling, this can be mentioned using notations as given below
One employee works in only one organization But one organization can have many employees. Hence it is a
M:1 relationship and cardinality is Many-to-One (M :1)
In ER modeling, this can be mentioned using notations as given below.
One student can enroll for many courses and one course can be enrolled by many students. Hence it is a M:N
relationship and cardinality is Many-to-Many (M:N)
In ER modeling, this can be mentioned using notations as given below
Relationship Participation
1. Total
In total participation, every entity instance will be connected through the relationship to another instance of the
other participating entity types
2. Partial
Example for relationship participation
Consider the relationship - Employee is head of the department.
Here all employees will not be the head of the department. Only one employee will be the head of the
department. In other words, only few instances of employee entity participate in the above relationship. So
employee entity's participation is partial in the said relationship.
However each department will be headed by some employee. So department entity's participation is total in the
said relationship.
Advantages and Disadvantages of ER Modeling ( Merits and Demerits of ER
Modeling )Advantages
1. ER Modeling is simple and easily understandable. It is represented in business users language and
it can be understood by non-technical specialist.
2. Intuitive and helps in Physical Database creation.
3. Can be generalized and specialized based on needs.
4. Can help in database design.
5. Gives a higher level description of the system.
Disadvantages
1. Physical design derived from E-R Model may have some amount of ambiguities or inconsistency.
2. Sometime diagrams may lead to misinterpretations