Data Models in DBMS
Data Models in DBMS
It organizes
To organize It organizes
records in the
records, it uses records in the
form of directed
tree structure. form of tables.
graphs.
In addition to In addition to
It implements 1:1 and 1:n it 1:1 and 1:n it
1:1 and 1:n also implements also implements
relations. many to many many to many
relationships. relationships.
rows and
relationships relationship columns to
among records among records depict
physically. physically. relationship
among records.
Insertion
anomaly exits in
this model i.e.
There is no There is no
child node
insertion insertion
cannot be
anomaly. anomaly.
inserted without
the parent
node.
Deletion
anomaly exists
There is no There is no
in this model i.e.
deletion deletion
it is difficult to
anomaly. anomaly.
delete the
parent node.
Hierarchical Data Network Data Relational Data
Model Model Model
There is partial
This model lacks This model
data
data provides data
independence
independence. independence.
in this model.
Difficult to
design a
database and It is easy to
Difficult to manipulate a comprehend
design a database due to
database because of its concealed
because of its complexity. physical level
complexity. Hence, it details from
imposes a end-users.
burden on the
programmer.
It is flexible as It is flexible as
compared to compared to the
It is less flexible.
the hierarchical hierarchical
model. model.
UNIVAC and
applications.
model. SUPRADBMS’s
Oracle, SQL.
use this model.
It is difficult to achieve
It is easier to achieve than
compared to physical
logical independence.
independence.
Example- change in
compression Example –
technology, hashing adding/modifying or
algorithm, storage deleting a new attribute.
device etc.
Conclusion
The data independence property of the database is an
expected property that relies on separating the logical
and physical aspects of storing and accessing data. This
means that it is easy to make structural modifications
to the database without affecting the applications that
use it. This is a situation that impacts the capacity of
the organization to remain adaptable in the dynamic
business environment, as well as making sure that the
technological advancements within the organization
are interoperable over a long period of time.
KEYS:
Keys are one of the basic requirements of a relational
database model. It is widely used to identify the
tuples(rows) uniquely in the table. We also use keys to
set up relations amongst various columns and tables of
a relational database.
Different Types of Database Keys
Candidate Key
Primary Key
Super Key
Alternate Key
Foreign Key
Composite Key
To master the concepts of keys and other essential
topics in databases, consider enrolling in the GATE CS
Self-Paced course . This course provides in-depth
coverage of core subjects, helping you build a strong
foundation for GATE and other competitive exams,
while enhancing your understanding of critical
computer science principles.
Candidate Key
The minimal set of attributes that can uniquely identify
a tuple is known as a candidate key. For Example,
STUD_NO in STUDENT relation.
It is a minimal super key.
It is a super key with no repeated data is called a
candidate key.
The minimal set of attributes that can uniquely
identify a record.
It must contain unique values.
It can contain NULL values.
Every table must have at least a single candidate
key.
A table can have multiple candidate keys but only
one primary key.
The value of the Candidate Key is unique and may
be null for a tuple.
There can be more than one candidate key in a
relationship.
Example:
STUD_NO is the candidate key for relation STUDENT.
Table STUDENT
12345678
1 Shyam Delhi
9
22336579
2 Rakesh Kolkata
6
17546896
3 Suraj Delhi
5
1 001 C001
2 056 C005
12345678
1 Shyam Delhi
9
22336579
2 Rakesh Kolkata
6
17546896
3 Suraj Delhi
5
Super Key
The set of attributes that can uniquely identify a tuple
is known as Super Key. For Example, STUD_NO,
(STUD_NO, STUD_NAME), etc. A super key is a group of
single or multiple keys that identifies rows in a table. It
supports NULL values.
Adding zero or more attributes to the candidate
key generates the super key.
A candidate key is a super key but vice versa is not
true.
Super Key values may also be NULL.
Example:
Consider the table shown above.
STUD_NO+PHONE is a super key.
1 005 C001
2 056 C005
1 kartik 01.01.2003
2 yash 01.01.2004
roll_no name DOB
adity
3 12.12.2003
a
Roll_no
. Name Address Personal_id
ER MODEL
The Entity Relational Model is a model for identifying
entities to be represented in the database and
representation of how those entities are related. The
ER data model specifies enterprise schema that
represents the overall logical structure of a database
graphically.
The Entity Relationship Diagram explains the
relationship among the entities present in the
database. ER models are used to model real-world
objects like a person, a car, or a company and the
relation between these real-world objects. In short, the
ER Diagram is the structural format of the database.
Why Use ER Diagrams In DBMS?
ER diagrams represent the E-R model in a
database, making them easy to convert into
relations (tables).
ER diagrams provide the purpose of real-world
modeling of objects which makes them intently
useful.
ER diagrams require no technical knowledge and
no hardware support.
These diagrams are very easy to understand and
easy to create even for a naive user.
It gives a standard solution for visualizing the data
logically.
A solid grasp of the ER Model is crucial for excelling in
exams like GATE, where database management is a key
topic. To enhance your understanding and boost your
exam preparation, consider the GATE CS Self-Paced
Course . This course offers in-depth coverage of the ER
Model and other essential database concepts, helping
you build the knowledge needed to succeed in your
exams.
Symbols Used in ER Model
ER Model is used to model the logical view of the
system from a data perspective which consists of these
symbols:
Rectangles: Rectangles represent Entities in the ER
Model.
Ellipses: Ellipses represent Attributes in the ER
Model.
Diamond: Diamonds represent Relationships
among Entities.
Lines: Lines represent attributes to entities and
entity sets with other relationship types.
Double Ellipse: Double Ellipses represent Multi-
Valued Attributes.
Double Rectangle: Double Rectangle represents a
Weak Entity.
Symbols used in ER Diagram
Components of ER Diagram
ER Model consists of Entities, Attributes, and
Relationships among Entities in a Database System.
Components of ER Diagram
What is Entity?
An Entity may be an object with a physical existence – a
particular person, car, house, or employee – or it may
be an object with a conceptual existence – a company,
a job, or a university course.
What is Entity Set?
An Entity is an object of Entity Type and a set of all
entities is called an entity set. For Example, E1 is an
entity having Entity Type Student and the set of all
students is called Entity Set. In ER diagram, Entity Type
is represented as:
Entity Set
We can represent the entity set in ER Diagram but can’t
represent entity in ER Diagram because entity is row
and column in the relation and ER Diagram is graphical
representation of data.
Types of Entity
There are two types of entity:
1. Strong Entity
A Strong Entity is a type of entity that has a key
Attribute. Strong Entity does not depend on other
Entity in the Schema. It has a primary key, that helps in
identifying it uniquely, and it is represented by a
rectangle. These are called Strong Entity Types.
2. Weak Entity
An Entity type has a key attribute that uniquely
identifies each entity in the entity set. But some entity
type exists for which key attributes can’t be defined.
These are called Weak Entity types .
For Example, A company may store the information of
dependents (Parents, Children, Spouse) of an
Employee. But the dependents can’t exist without the
employee. So Dependent will be a Weak Entity
Type and Employee will be Identifying Entity type for
Dependent, which means it is Strong Entity Type .
A weak entity type is represented by a Double
Rectangle. The participation of weak entity types is
always total. The relationship between the weak entity
type and its identifying strong entity type is called
identifying relationship and it is represented by a
double diamond.
Attribute
Types of Attributes
1. Key Attribute
The attribute which uniquely identifies each entity in
the entity set is called the key attribute. For example,
Roll_No will be unique for each student. In ER diagram,
the key attribute is represented by an oval with
underlying lines.
Key Attribute
2. Composite Attribute
An attribute composed of many other attributes is
called a composite attribute. For example, the Address
attribute of the student Entity type consists of Street,
City, State, and Country. In ER diagram, the composite
attribute is represented by an oval comprising of ovals.
Composite Attribute
3. Multivalued Attribute
An attribute consisting of more than one value for a
given entity. For example, Phone_No (can be more than
one for a given student). In ER diagram, a multivalued
attribute is represented by a double oval.
Multivalued Attribute
4. Derived Attribute
An attribute that can be derived from other attributes
of the entity type is known as a derived attribute. e.g.;
Age (can be derived from DOB). In ER diagram, the
derived attribute is represented by a dashed oval.
Derived Attribute
The Complete Entity Type Student with its Attributes
can be represented as:
Entity and Attributes
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. In ER diagram, the relationship
type is represented by a diamond and connecting the
entities with lines.
Entity-Relationship Set
A set of relationships of the same type is known as a
relationship set. The following relationship set depicts
S1 as enrolled in C2, S2 as enrolled in C1, and S3 as
registered in C3.
Relationship Set
Degree of a Relationship Set
The number of different entity sets participating in a
relationship set is called the degree of a relationship
set.
1. Unary Relationship: When there is only ONE entity
set participating in a relation, the relationship is called
a unary relationship. For example, one person is
married to only one person.
Unary Relationship
2. Binary Relationship: When there are TWO entities
set participating in a relationship, the relationship is
called a binary relationship. For example, a Student is
enrolled in a Course.
Binary Relationship
3. Ternary Relationship: When there are three entity
sets participating in a relationship, the relationship is
called a ternary relationship.
4. N-ary Relationship: When there are n entities set
participating in a relationship, the relationship is called
an n-ary relationship.
What is 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:
1. 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 one
female and a female can marry one male. So the
relationship will be one-to-one.
the total number of tables that can be used in this is 2.