DBMS-Module-1
DBMS-Module-1
School of Computer
Science Engineering
Module 1
Introduction to Database System
Introduction to Database system
Purpose of database system, view of data,
Independence, relational databases, Database
Language, Database System architecture - levels,
Mappings,
7
WHY DBMS
Data Redundancy is more in file management system. Data Redundancy is less in database management
system.
Data Inconsistency is more in file system. Data Inconsistency is less in database management
system.
Centralisation is hard to get when it comes to File Centralisation is achieved in Database Management
Management System. System.
User locates the physical address of the files to access In Database Management System, user is unaware of
data in File Management System. physical address where data is stored.
Security is low in File Management System. Security is high in Database Management System.
File Management System stores unstructured data as Database Management System stores structured data
isolated data files/entities. which have well defined constraints and interrelation.
ADVANTAGES
• Hierarchical databases
• Network databases
• Object oriented databases
• Relational databases
Hierarchical DBMS(HDBMS)
1968-1980 was the era of the Hierarchical
Database. Prominent hierarchical database
model was IBM's first DBMS.
It was called IMS (Information Management
System).
In this model, files are related in a parent/child
manner.
Tree like structure.
20
Network DBMS
A network database model is a database model
that allows multiple records to be linked to the
same owner file.
In this model, files are related as owners and
members, like to the common network model.
Object oriented DBMS
Relational Database (Tabular)
1970 - Present: It is the era of Relational
Database and Database Management. In 1970,
the relational model was proposed by E.F. Codd.
Relational database model has two main
terminologies called instance and schema.
The instance is a table with rows or columns
This model uses some mathematical concept like
set theory and predicate logic.
The first internet database application had been
created in 1995.
During the era of the relational database, many
more models had introduced like object-oriented
model, object-relational model, etc.
23
Relational databases
DBMS Architecture
• The DBMS design depends upon its
architecture. The basic client/server
architecture is used to deal with a large
number of PCs, web servers, database
servers and other components that are
connected with networks.
Conceptual
Or
Logical
Internal
Or
Physical
Data Independence
• Logical Data Independence:
• The capacity to change the conceptual schema without
having to change the external schemas and their
associated application programs.
45
E-R Diagram
student
Multivalued attribute Multivalued attributes can have more than one values.
Ex:- A student can have more than one mobile number, email
address, etc.
Key Attribute The key attribute is used to represent the main characteristics of
an entity. It represents a primary key. The key attribute is
represented by an ellipse with the text underlined.
Ex: Rollno is a key attribute as it can identify any student
uniquely.
Single Valued Attribute Single valued attributes are those attributes which can take only
one value for a given entity from an entity set. Ex: Age, DoB,
Rollno, etc.
Key Attributes
• Keys play an important role in the relational
database.
• It is used to uniquely identify any entity or record
or row of data from the table. It is also used to
establish and identify relationships between tables.
• Types of Key Attributes
• Primary Key
• Candidate Key
• Super Key
• Alternate Key
• Foreign Key
• Composite Key
• Surrogate Key
Primary key and Candidate Key
• It is the first key used to identify one and only one instance of an
entity uniquely. An entity can contain multiple keys. The key which
is most suitable from those lists becomes a primary key.
• For each entity, the primary key selection is based on
requirements and developers.
• A candidate key is an attribute or set of attributes that can
uniquely identify a tuple.
• Except for the primary key, the remaining attributes are
considered a candidate key. The candidate keys are as strong as
the primary key.
• Super Key
• Super key is an attribute set that can uniquely identify a tuple. A super key
is a superset of a candidate key.
• Foreign key
• Foreign keys are the attribute of the table used to point to the primary key
of another table.
• Composite key
• Whenever a primary key consists of more than one attribute, it is known as
a composite key. This key is also known as Concatenated Key.
• Alternate key
• The total number of the alternate keys is the total number of candidate
keys minus the primary key
• Surrogate key
• Surrogate key also called a synthetic primary key, is generated when a new
record is inserted into a table automatically by a database that can be
declared as the primary key of that table . It is the sequential number
outside of the database that is made available to the user.
Student
Roll No. Regd. No. Name gender E-mail DOB
1 100100 Abc male abc@gmail.c 12-03-2003
om
2 100230 Xyz Female xyz@gmail.co 03-02-2001
m
3 100536 Pqr Female pqr@gmail.c 15-05-2002
om
4 100469 Dhr Male dhr@gmail.c 08-04-2002
om
57
One-to-many − One entity from entity set A can be associated
with more than one entities of entity set B however an entity
from entity set B, can be associated with at most one entity.
58
Many-to-one − More than one entities from entity set A can be
associated with at most one entity of entity set B, however an
entity from entity set B can be associated with more than one
entity from entity set A.
59
Many-to-many − One entity from A can be associated with more
than one entity from B and vice versa.
60
Weak Entities
A weak entity is a type of entity which doesn't have its key
attribute.
61
Strong Entity Weak Entity
Strong entity always have one Weak entity have a foreign key
primary key. referencing primary key of strong
entity.
Strong entity is independent of Weak entity is dependent on
other entities. strong entity.
A strong entity is represented by A weak entity is represented by
single rectangle. double rectangle.
Relationship between two strong Relationship between a strong and
entities is represented by single weak entity is represented by
diamond. double diamond.
Entity1 Entity2
HasLinkWith
Binary relationship
S u p e rv is o r Supe rv ise s
Entity1
Staff Recursive (Unary) relationship
- example
S u p e rv is e e
Entity1 Entity3
Te rnaryRe lationship
Complex relationship
–
here ternary Entity2
65
Relationships: Multiplicity
label lines to show cardinality and participation
0..1 “zero or one” optional
0..* “zero or more”
1..1 “one”
1..4 “between 1 and 4” mandatory
1..* “one or more”
Entity1 Entity2
HasLinkWith
1..1 0..*
Manages
Manager Department
1..1 0..3
Manages
responsibility [1..*]
dateAllocated
Each manager
Each manages UP TO 3
department departments
is managed Relationship (but need not
by ONE attributes manage any
manager department) 67
FEATURES OF ER-diagram
Generalization
• Generalization is like a bottom-up approach in which two or
more entities of lower level combine to form a higher level
entity if they have some attributes in common.
• Entities are combined to form a more generalized entity, i.e.,
subclasses are combined to make a superclass.
IS A
Specialization
• This is a top-down approach, and it is opposite to
Generalization.
• This is used to identify the subset of an entity set that shares
some distinguishing characteristics.
IS A
Aggregation
• Where the relation between two entities is treated as a single
entity.
• Where relationship with its corresponding entities is
aggregated into a higher level entity.
ENQUIRE
E-R Diagram Steps
Here we are going to design an Entity Relationship (ER) model
for a college database . Say we have the following statements.
1. A college contains many departments
2. Each department can offer any number of courses
3. Many instructors can work in a department
4. An instructor can work only in one department
5. For each department there is a Head
6. An instructor can be head of only one department
7. Each instructor can take any number of courses
8. A course can be taken by only one instructor
9. A student can enroll for any number of courses
10. Each course can have any number of students 72
Step 1 : Identify the Entities
73
Step 2 : Identify the relationships
1. One department offers many courses. But one particular course
can be offered by only one department. hence the cardinality
between department and course is One to Many (1:N)
2. One department has multiple instructors . But instructor belongs
to only one department. Hence the cardinality between
department and instructor is One to Many (1:N)
3. One department has only one head and one head can be the
head of only one department. Hence the cardinality is one to
one. (1:1)
4. One course can be enrolled by many students and one student
can enroll for many courses. Hence the cardinality between
course and student is Many to Many (M:N)
5. One course is taught by only one instructor. But one instructor
teaches many courses. Hence the cardinality between course and
instructor is Many to One (N :1)
74
Step 3: Identify the key attributes
• "Department_Name" can identify a department uniquely.
Hence Department_Name is the key attribute for the Entity
"Department".
• Course_ID is the key attribute for "Course" Entity.
• Student_ID is the key attribute for "Student" Entity.
• Instructor_ID is the key attribute for "Instructor" Entity.
76
BANKING SYSTEM
• ER diagram of Bank has the following description :