DBMS Unit-1
DBMS Unit-1
MANAGEMENT SYSTEM
(DBMS)
PC-CS-301A
UNIT-1
SYLLABUS: UNIT-1
Introduction: Concept & Overview of DBMS,
Data Models: Network, Hierarchical and
Relational Model, Levels of abstraction.
Administrator, Database Users, Three Schema
architecture of DBMS, Application.
Information
Information is organised or classified data.
It is a collection of related data.
Processed data is called as Information.
3
KEY ATTRIBUTES OF INFORMATION
Accuracy
The information should be free from errors.
It should clearly and accurately reflect the meaning
of data on which it is based.
Timeliness
The recipient should receive the information within
the required time frame.
Relevancy
The relevancy or usefulness of the piece of
4
information for the corresponding person.
BASIC DEFINITIONS
Meta Data
It is the data about data.
It describes the database structure, sizes of data
types, constraints, applications, authorization etc.
that are used as an integral tool for information
resource management.
Data Dictionary
It contains the information of data stored in the
database.
It stores meta data i.e. information about the
database, attribute names and definitions for each 5
table in the database.
DATABASE
Database
Database is a collection of Inter related data.
It is organised to store, manage and access the
information.
E.g. Telephone directory, Dictionary
Database
Management
System
Management
Database
System 7
CONTD...
DBMS
DBMS is a set of programs that provide a lot of
functionalities to store, manage, manipulate and access
information from a database in an efficient way.
MS SQL Server
PRIMARY FUNCTIONS OF DBMS
Define, create and organise a database
It defines the schemas and sub-schemas using DDL (Data
Definition Language).
Input Data
Enters data into the database with input devices.
Process Data
Manipulation and Processing of data stored in the database
using DML (Data Manipulation Language)
Query Database 9
Information can be accessed from the database querying the
database using SQL.
COMPONENTS OF DBMS
10
COMPONENTS OF DBMS
DBMS has three main components:
Data Definition Language (DDL)
Defines the database, specify the data types, data structures
and constraints on the data to be stored in database.
12
Libraries: to maintain information about books
etc.
TRADITIONAL FILE PROCESSING
Data Inconsistency
15
INTEGRATED DATABASE ENVIRONMENT
Large repository of data known as database, which
can used simultaneously by many users.
All data is stored together with minimum
redundancy.
It is a shared source.
Managed by database administrator who is
responsible for designing, creating and
maintaining the database to satisfy the need of
users.
The access to the database is controlled by DBMS.
Allows concurrent use of data without having users
interface with each other.
Performs backup and recovery procedures 16
automatically.
ADVANTAGES OF DATABASE SYSTEM
Minimal Redundancy
Data Consistency
Sharing of data
Search capability
Concurrency Control
17
Privacy and security
DISADVANTAGES OF DATABASE SYSTEM
18
COMPARISON
File System Approach Database Approach
20
CONTD...
Data
Hardware
Consists of secondary storage volumes like disks, drums etc.
on which database is stored with the associated devices,
control channels etc.
Software
There is software between hardware and user.
It is called as DBMS.
All the requests from the user to access the database are
handled by the DBMS.
Users
Database users interact with data to update, read and
modify the given information on a daily basis. 21
There are different types of database users
DATABASE USERS
System Analyst
End Users
22
DATABASE ADMINISTRATOR (DBA)
23
RESPONSIBILITIES OF DBA
Deciding the information contents of the
database system.
Security administration.
28
CONTD...
Casual End Users
They occasionally access the database, but they may need
different information each time.
Standalone Users
These users maintain personal databases by using ready 29
made program packages that provide easy to use menu
based or graphic based interfaces.
CONTD...
Sophisticated Users
These are the users who creates, updates,
deletes the database.
complex requirements.
DATABASE SCHEMAS & INSTANCES
The description of database like the names of
entities and attributes and the relationship
among them is called the Database Schema.
32
THREE LEVEL ARCHITECTURE OF DBMS
Themajor purpose of a database system is
to provide users with an abstract view of
data.
same database.
CONCEPTUAL LEVEL
Thislevel describes what data are stored in
the database and the relationship among
the data.
User operations.
INTERNAL LEVEL
This is the lowest level of abstraction that
describes how the data is actually stored.
This level describes complex low level data
structures in detail.
This level is also called physical level.
It
can be defined as the capacity to change
the schema at one level of database system
without having to change the schema at
next higher level.
SDL/ DSDL
Used to specify the internal schema in the database.
Mappings between the conceptual and internal
schame
Storage structure and access methods used by the 43
database system.
...CONTD
VDL
Specify user’s views and their mappings to
conceptual schema
Generally, DDL is used for both conceptual and
external schema.
DML
Retrieves data and records from the database
Adds records to the database
Deletes records
Retrieve records
sequentially according to key
In physically recorded sequence
44
Modify records that have been updated
Rewrite records that have been updated
...CONTD
Procedural DML
There is an application program which
issues an instruction to the DBMS to find
certain data in the database and returns it
to the program.
PDML allows the user to tell the system
what data is needed 45
Non-Procedural DML
Allows the user to state what data is
required irrespective of how it is retrieved.
Queries are applied directly to the DBMS to
find certain data and returns the same to
the display screen.
46
DATA MODELS
A data model is a collection of concepts that can be
used to describe the structure of the database
including data types, relationships and the constraints
that apply on the data.
50
HIERARCHICAL DATA MODEL
Advantages
It is simple & efficient.
Maintains data integrity.
Provides the concept of data security.
Disadvantages
It is complex to implement
Lack of flexibility.
Data management is difficult.
51
NETWORK DATA MODEL
Network Model was designed to overcome the
limitations of Hierarchical Data Model.
52
NETWORK DATA MODEL
Advantages
Conceptually simple
Promotes database integrity
Flexibility in accessing data
Disadvantages
Complex structure
Lack of structural independence.
53
NETWORK DATA MODEL
54
RELATIONAL DATA MODEL
Relational model can represent as a table with columns
and rows.
56
RELATIONAL DATA MODEL
Advantages
Easy to use and understand
Very flexible
Widely used
Security control and authorization are easy to
implement
Data independence
Disadvantages
Performance degrades for large databases.
Index must be maintained in the database which
requires sequential search. It increases time
complexity.
57
E-R MODEL
E-R stands for Entity-Relationship Model
describe it.
COMPONENTS OF E-R MODEL
59
ATTRIBUTES
Attributes are properties used to describe an
entity. For example an EMPLOYEE entity may
have a Name, SSN, Address, Gender, BirthDate.
Complex Attributes
Key Attribute
61
TYPES OF ATTRIBUTES
An attribute that cannot be further
subdivided into components is called
Simple Attribute.
E.g. Rollno of a student
63
TYPES OF ATTRIBUTES
Stored and derived attributes
Attributes can also derived from other
attributes
e.g. age can be derived from date of birth &
current date.
Age is called derived attribute and date of
birth is a stored attribute.
67
TYPES OF ENTITY TYPES
Strong Entity Type
The entity types having a key attribute.
The primary key helps in identifying each entity uniquely.
It is represented by a rectangle.
E.g. In STUDENT, Roll_no identifies each element of the table
uniquely and hence, we can say that STUDENT is a strong
entity type.
69
ENTITY SET
Entity Set is a collection of entities of the same entity
type.
E.g. In the previous example of STUDENT entity type, a
collection of entities from the Student entity type would
form an entity set.
70
COMPONENTS OF E-R DIAGRAM
71
RELATIONSHIP TYPE
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.
72
RELATIONSHIP SET
A relationship set is a set of relationships of the same
type.
Consider an example, employees work in different
departments.
Then relationship exists between employees and
departments because each employee must belongs to some
department.
Relation of all employees with department when combined
makes the relationship set because each employee has same
kind of relation with departments.
73
DEGREE OF A RELATIONSHIP TYPE
The degree of a relationship type is the number of
participating entity types.
Binary relationship
Has 2 entity types linked together.
Ternary relationship
If there are 3 entity types linked together.
74
ROLE NAMES & RECURSIVE RELATIONSHIPS
The Role name signifies the role that the
participating entity from the entity type plays in
each relationship instance.
Participation constraints.
MAPPING CARDINALITY/ CARDINALITY RATIO
There
are four types of Cardinality Ratio in
Database Management Systems:
One to one (1:1)
One to many (1:N)
Many to one (N:1)
Many to many (M:N) 77
ONE TO ONE CARDINALITY
When a single instance of an entity is associated with
a single instance of another entity, it is called as One
to One Cardinality
e.g. one student can have only one student id, and one
student id can belong to only one student.
78
ONE TO MANY CARDINALITY
When is a single instance of an entity is
associated with more than one instance of
another entity, this type of relationship is
called One to Many Relationships.
E.g. Many students can study in a single college
but the student cannot register to more than one
college at the same time
79
MANY TO ONE CARDINALITY
When entities in one entity set can participate
only once in a relationship set and entities in
another entity can participate more than once in
the relationship set, then such type of cardinality
is called Many to One.
E.g. a student can join only one college but a college
can admit any number of students
80
MANY TO MANY CARDINALITY
More than one instance of an entity is associated
with more than one instance of another entity.
E.g. a student can take more than one course and the
single course can be taken by any number of students
It is represented by M: N or N: M
81
PARTICIPATION CONSTRAINTS
It tells the participation of entity set in relationship
sets.
Partial participation
If only some entities from entity set E is participating in
relationships in set R then it is known as Partial participation.
In the manages relationship every employee cannot be MANAGER 82
of the department,so the participation of EMPLOYEE in the
MANAGES relationship is partial.
PARTICIPATION CONSTRAINTS
83
PARTICIPATION CONSTRAINTS
84
RELATIONSHIP BETWEEN CARDINALITY
AND PARTICIPATION CONSTRAINTS
87
CANDIDATE KEY
A candidate key is an attribute or set of attributes that can
uniquely identify a tuple.
88
PRIMARY KEY
It is the first key used to identify one and only one instance of an entity
uniquely.
An entity can contain multiple keys but the key which is most suitable
becomes a primary key.
E.g. In the EMPLOYEE table, ID can be the primary key since it is unique for
each employee.
We can even select License_Number and Passport_Number as primary keys
since they are also unique.
For each entity, the primary key selection is based on requirements and
developers.
89
FOREIGN KEY
Foreign keys are the attributes of the table used to
point to the primary key of another table.
E.g. Every employee works in a specific department in
a company, and employee and department are two
different entities.
Therefore, we link these two tables through the
primary key of one table.
In the EMPLOYEE table, Department_Id is the
foreign key, and both the tables are related.
90
ALTERNATE KEY
There may be one or more attributes or a combination of attributes
that uniquely identify each tuple in a relation.
These attributes or combinations of the attributes are called the
candidate keys.
One key is chosen as the primary key from these candidate keys,
and the remaining candidate key, if it exists, is termed the
alternate key.
If there is only one candidate key in a relation, it does not have an
alternate key.
For example, employee relation has two attributes, Employee_Id and
PAN_No, that act as candidate keys.
Employee_Id is chosen as the primary key
PAN_No, acts as the Alternate key.
91
COMPOSITE KEY
A composite Key is a set of two or more attributes
that help identify each tuple in a table uniquely.
The attributes in the set may not be unique when
considered separately.
However, when taken all together, they will
ensure uniqueness.
The ‘Concatenated Key’ is another name for a
composite key.
92
UNIQUE KEY
Unique Key is a column or set of columns that
uniquely identify each record in a table.
A unique Key differs from a primary key because
it can have only one null value, whereas a primary
Key cannot have any null values.
E.g. driving_license attribute in EMPLOYEE table can
be a unique key but an employee may not have a
driving_license.
So, it has a unique value but can be null.
93
RELATION BETWEEN PRIMARY KEY,
CANDIDATE KEY & SUPER KEY
94
ENTITY RELATIONSHIP DIAGRAM
The Entity Relationship Model is a model for identifying
entities to be represented in the database and
representation of how those entities are related.
97
E-R DIAGRAM: AN EXAMPLE
Make an E-R diagram with entities Customer, Loan
and Payment
98
ADVANTAGES OF E-R MODEL
Conceptually Simple
ER model is very simple
if the relationship between entities and attributes is known, we can
easily draw an ER diagram.
103
GENERALIZATION
Generalization is the process of extracting
common properties from a set of entities and
creating a generalized entity from it.
105
AGGREGATION
An ER diagram is not capable of representing the
relationship between an entity and a relationship which may
be required in some scenarios.
Using aggregation,
WORKS_FOR relationship with its entities EMPLOYEE and PROJECT
is aggregated into a single entity and 106
relationship REQUIRE is created between the aggregated entity and
MACHINERY.
AGGREGATION
107
EXAMPLE
108
REDUCTION OF ER & EER DIAGRAM
INTO TABLES
109
Following points are to be considered:
Reduction of Strong Entity Sets into Tables
For a strong entity set E and having n number of
columns or table name is equal to entity set name and
number of columns is equal to number of attributes.
Reduction of Generalization
111
Reduction of Aggregation
E-R MODEL OF EMPLOYEE & DEPARTMENT ENTITY SETS
112