DBMS Sem-Ii Unit-Ii
DBMS Sem-Ii Unit-Ii
Unit-II : Data Models – Types of Data Models, Codd’s Rules, Comparison of various Data
Models, Types of Database Systems, Comparison between Client/Server and Distributed
Database Systems, Comparison between DBMS and RDBMS.
Data Model
A data model can be defined as an integrated collection of concepts describing and
manipulating data, as well as constraints on the data within an organization. A data
model is not just a set of tables; it is a conceptual representation of physical data
stored in the database.
For example, if you have a table with a column for each employee's name, then there
are many possible ways to represent this information: as one row per employee, or as
multiple rows per employee (one row per department), or as multiple rows per person
(one row for each job title). Each of these models has its own strengths and
weaknesses.
The first step in designing a data model is to define what kind of data you want to store
in your database. This usually involves defining the entities involved in your application.
An entity is any object that exists independently of anything else. You might think about
an entity as something like a "person" or an "address." Once you've identified all the
entities, you need to decide how they relate to each other. In most cases, the answer
to this question depends on what type of business process you're modeling.
The next step is to figure out how those entities will interact with each other. In some
applications, you may want to create a single table to hold all the data about a
particular entity. However, you could also use several tables, where each table holds
only part of the data about an individual entity.
In addition, you should consider whether you'll need to perform queries across more
than one table. If so, you'll probably need to link them together using foreign key
columns.
Once you know the basic structure of your data model, you can start thinking about
how best to organize it into tables. There are two main approaches: relational
databases and hierarchical databases. Relational databases are organized around a
set of tables that share common fields. Hierarchical databases are organized around a
tree-like structure called a hierarchy. Both approaches allow you to build complex
structures quickly, but they do so at the cost of flexibility.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 1
Why use Data Models?
Data Models are extremely useful for any organization as it lets business users directly
define core business rules. As a result, fewer revisions are required during
implementation. It also leads to significant reductions in the development time, allowing
businesses to deliver new businesses and projects faster.
Overall, the advantages of using data models can be summed up briefly in the
following way:
1. Helps to cut costs and deliver products faster
2. It improves business processes significantly
3. Reduces complexity and risks in data handling
Now, let's discuss the various types of data models in DBMS in detail.
1. A Hierarchical Model
The hierarchical data model was the first DBMS-based model. This model organizes
data in a hierarchical tree structure. The hierarchy begins at the root, which contains
root data. It then expands into a tree adding child nodes to the parent node. This model
can easily represent some real-world relationships, such as sitemaps and recipes for
food, or even website navigation.
Example: The relationship between different kinds of humans can be represented in
the following manner:
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 2
Characteristics of Hierarchical Model:
1. One to many relationships: Here, the data is organized in a tree-like manner
where there is a one-to-many relationship between data types. There can only
be one path from any parent to any node. Example: If we want to get to the root
node, there is only one way to do so. It's through the men's shoe node.
2. Parent-Child Relationship Every child node has its parent node, but a parent can
have more than one child. Multiple parents are prohibited.
3. Deletion Issue: When a parent node has been deleted, the child node will also
be deleted.
4. Pointers: Pointers link the parent and child nodes. They are used for navigation
between stored data.
Example: The visual representation of the basic concepts of the database schema is
shown below where the human node points to two other nodes, the Women, and
the Men. This example is explained by taking real-world entities.
2. Network Model
This model is an extension of the hierarchical one. This model was the most well-known
before the relational one. The hierarchical model can have multiple records. This model
is identical to the hierarchical one. It replaces the hierarchical trees with a graph.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 3
Example: In this example, we can see that a node student has two parents, Department
and Library. In the hierarchical structure, this was not possible.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 4
ER Model diagram makes it easy for developers to see the system. The E-R model
Diagram is used to show an ER Model or domain model. The following components
make up the ER Diagram:
Entity: A real-world thing, entity. It could be a person, a place, or even an
idea. Examples: Students, Teachers, Courses, Buildings, Departments, etc. are
all examples of entities that make up a School Management system.
Attributes: An entity can contain a real-world property called an attribute. These
are the attributes of the attribute. Example: An entity student owns the property
student id and age, and so forth.
Relationship - Relationship shows how two attributes are related. Example: A
student working in a department.
The entities in the diagram are student and course. Student entity attributes are
Student_Id and Student_Age. Entity Course has the attributes Course_Id and
Course_Credits. These entities are linked using the relationship. Each student works in
a specific department.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 5
Hidden Information: There is some information that might be lost or hidden
within the ER model. It is possible that some information may be lost or hidden
because it is a high-level view.
4. Relational Model
The relational model is the most popular model. It is a model where the information is
stored as two-dimensional tables. All information is stored in rows and columns. The
foundation of a model that is relational is tables. Therefore the tables are known
as relations within the model. Examples: In this example, there is a student data table.
However, these issues are insignificant when compared to the benefits associated with
the relationship model. The problems could be prevented with the proper
implementation and management.
In the example above we have an object of the customer (or a single parent node). The
data and relationships for each object are organized as a single entity. The primary key
such as Bank Account, Pune_Address, and the Delhi_Address as well as the
processes that will be used by that object are recorded in a single entity. The objects
are linked via the same attribute i.e the Customer_Name. The communication between
them is done through this common identification. This is the representation of the
physical model of Object-oriented data model
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 7
Codd Rules
Codd rules were proposed by E.F. Codd which should be satisfied by relational model.
E.F Codd was a Computer Scientist who invented the Relational model for Database
management. Based on relational model, the Relational database was created. Codd
proposed 13 rules popularly known as Codd's 12 rules to test DBMS's concept against
his relational model. Codd's rules actually define what quality a DBMS requires in order
to become a Relational Database Management System (RDBMS). Till now, there is
hardly any commercial product that follows all the 13 Codd's rules. Even Oracle follows
only eight and half(8.5) out of 13. The Codd's 12 rules are as follows.
Rule zero
This rule states that for a system to qualify as an RDBMS, it must be able to manage
database entirely through the relational capabilities.
Rule 1: Information rule
1. In this model, to store data It organizes records to one It organizes records in the
hierarchy method is used. another through links or form of table and
It is the oldest method and pointers. relationship between
not in use today. tables are set using
common fields.
3. It implements 1:1 and 1:n In addition to 1:1 and 1:n it also In addition to 1:1 and 1:n it
relations. implements many to many also implements many to
relationships. many relationships.
4. Pointers are used to A linked list is used to establish The logical representation
establish relationships a relationship among records is used with rows and
among records physically. physically. columns to depict
relationship among
records.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 9
SN Hierarchical Data Model Network Data Model Relational Data Model
This model lacks data There is partial data This model provides data
8. independence. independence in this model. independence.
It is used to access the It is used to access the data It is used to access the
data which is complex and which is complex and data which is complex and
10. asymmetric. symmetric. symmetric.
&XML and XAML use this VAX-DBMS, DMS-1100 of It is mostly used in real
model. UNIVAC and SUPRADBMS’s world applications. Oracle,
13. use this model. SQL.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 10
ER model Relational model
It represents collection of entities and It represent data in the form of tables and
describes relationship between them. describes relationship between them.
Types of Databases
There are various types of databases used for storing different varieties of data:
1. Centralized Database
2. Distributed Database
3. Relational Database
4. Cloud Database
5. Object Oriented Database
6. Hierarchical Database
7. Network Database
8. Personal Database
1) Centralized Database
It is the type of database that stores data at a centralized database system. It comforts
the users to access the stored data from different locations through several applications.
These applications contain the authentication process to let users access data securely.
An example of a Centralized database can be Central Library that carries a central
database of each library in a college/university.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 11
Disadvantages of Centralized Database
o The size of the centralized database is large, which increases the response time
for fetching the data.
o It is not easy to update such an extensive database system.
o If any server failure occurs, entire data will be lost, which could be a huge loss.
2) Distributed Database
Unlike a centralized database system, in distributed systems, data is distributed among
different database systems of an organization. These database systems are connected
via communication links. Such links help the end-users to access the data
easily. Examples of the Distributed database are Apache Cassandra, HBase, Ignite,
etc.
We can further divide a distributed database system into:
3) Relational Database
This database is based on the relational data model, which stores data in the form of
rows(tuple) and columns(attributes), and together forms a table(relation). A relational
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 12
database uses SQL for storing, manipulating, as well as maintaining the data. E.F.
Codd invented the database in 1970. Each table in the database carries a key that
makes the data unique from others. Examples of Relational databases are MySQL,
Microsoft SQL Server, Oracle, etc.
A means Atomicity: This ensures the data operation will complete either with success
or with failure. It follows the 'all or nothing' strategy. For example, a transaction will
either be committed or will abort.
C means Consistency: If we perform any operation over the data, its value before and
after the operation should be preserved. For example, the account balance before and
after the transaction should be correct, i.e., it should remain conserved.
I means Isolation: There can be concurrent users for accessing data at the same time
from the database. Thus, isolation between the data should remain isolated. For
example, when multiple transactions occur at the same time, one transaction effects
should not be visible to the other transactions in the database.
D means Durability: It ensures that once it completes the operation and commits the
data, data changes should remain permanent.
4) Cloud Database
It is a type of database where data is stored in a virtual environment and executes over
the cloud computing platform. It provides users with various cloud computing services
(SaaS, PaaS, IaaS, etc.) for accessing the database. There are numerous cloud
platforms, but the best options are:
o Amazon Web Services(AWS)
o Microsoft Azure
o Kamatera
o PhonixNAP
o ScienceSoft
o Google Cloud SQL, etc.
5) Object-oriented Databases
It is the type of database that uses the object-based data model approach for storing
data in the database system. The data is represented and stored as objects which are
similar to the objects used in the object-oriented programming language.
6) Hierarchical Databases
It is the type of database that stores data in the form of parent-children relationship
nodes. Here, it organizes data in a tree-like structure.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 13
Data get stored in the form of records that are connected via links. Each child record in
the tree will contain only one parent. On the other hand, each parent record can have
multiple child records.
7) Network Databases
It is the database that typically follows the network data model. Here, the representation
of data is in the form of nodes connected via links between them. Unlike the hierarchical
database, it allows each record to have multiple children and parent nodes to form a
generalized graph structure.
8) Personal Database
Collecting and storing data on the user's system defines a Personal Database. This
database is basically designed for a single user.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 14
Working of Client-server Database Architecture in DBMS
Basically client-server model defines how the server provides services to clients. Server
is a centralized computer that provides services to all attached clients. For example file
server, web server, etc. each the basic work of server to provide services to each client.
The client can be a laptop computer, tablets, and smart phones, etc. The server has
many types of relationship with clients. Many servers have one too many
relationships with clients. In one too many relationships many clients connected with
one server. When one client wants to communicate with the server, the server may be
accepted or rejects the request of clients. When the server computer accepts the
request of clients than server maintains a connection according to a defined protocol.
The protocol rules over the network.
That must be followed for any network connection. If the one client wants to send an
email over the network, it requests the server, the SMTP (the protocol that is SMPT is
standing for simple mail transfer protocol that used to transfer a mail over the network.
SMTP is a set of commands or commands that check authentication and the transfer of
email. When configuring the settings for your e-mail program, you usually need to set
the SMTP server to your local Internet Service Provider’s SMTP settings. After all
process, the server will transfer e-mail to the desired client.
Another example of a client-server model is online gaming.
2. Distributed DBMS :
In Distributed DBMS, data is distributed over the geographical site. Each site is a
complete database system site on its end but the different sites have to work together
because if any user wants to access the data it can easily access data anywhere in
the network as the data is stored at the user’s own computer.
Client can access only one server at a User can access many sites
1. time. simultaneously.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 17
SN Client/Server Distributed DBMS
If somehow server crashes, the whole The crash of one site does not stop
5. system stops. the entire system.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 19
1. Simple attributes
2. Composite attributes
3. Single valued attributes
4. Multi valued attributes
5. Derived attributes
6. Key attributes
1. Simple Attributes-
Simple attributes are those attributes which cannot be divided further.
Example-
Here, all the attributes are simple attributes as they cannot be divided further.
2. Composite attributes
Composite attributes are those attributes which are composed of many other simple
attributes.
Example-
Here, the attributes “Name” and “Address” are composite attributes as they are
composed of many other simple attributes.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 20
3. Single Valued Attributes-
Single valued attributes are those attributes which can take only one value for a given
entity from an entity set.
Example-
Here, all the attributes are single valued attributes as they can take only one specific
value for each entity.
Here, the attributes “Mob_no” and “Email_id” are multi valued attributes as they can
take more than one values for a given entity.
5. Derived Attributes-
Derived attributes are those attributes which can be derived from other attribute(s).
Example-
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 21
Here, the attribute “Age” is a derived attribute as it can be derived from the attribute
“DOB”.
6. Key Attributes-
Key attributes are those attributes which can identify an entity uniquely in an entity set.
Example-
Here, the attribute “Roll_no” is a key attribute as it can identify any student uniquely.
Relationship Set
A relationship set is a set of relationships of same type.
A set of relationships of same type is known as relationship set.
Example-
‘Enrolled in’ is a relationship that exists between entities Student and Course.
Example-
Set representation of above ER diagram is-
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 22
Degree of a Relationship Set-
The number of entity sets that participate in a relationship set is termed as the degree of
that relationship set. Thus,
On the basis of degree of a relationship set, a relationship set can be classified into the
following types-
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 23
1. Unary Relationship Set-
Unary relationship set is a relationship set where only one entity set participates in a
relationship set.
Example-
One person is married to only one person
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 24
4. N-ary Relationship Set-
N-ary relationship set is a relationship set where ‘n’ entity sets participate in a
relationship set.
Degree of Relations in DBMS
In DBMS, a degree of relationship represents the number of entity types that associate
in a relationship. For example, we have two entities, one is a student and the other is
a bag and they are connected with the primary key and foreign key. So, here we can
see that the degree of relationship is 2 as 2 entities are associating in a relationship.
Types of degree
Now, based on the number of linked entity types, we have 4 types of degrees of
relationships.
1. Unary
2. Binary
3. Ternary
4. N-ary
Let’s discuss them one by one with the help of examples.
Unary
In this type of relationship, both the associating entity type are the same. So, we can
say that unary relationships exist when both entity types are the same and we call
them the degree of relationship is 1. Or in other words, in a relation only one entity set
is participating then such type of relationship is known as a unary relationship.
Example: In a particular class, we have many students, there are monitors too. So,
here class monitors are also students. Thus, we can say that only students are
participating here. So the degree of such type of relationship is 1.
Binary (degree 2)
In a Binary relationship, there are two types of entity associates. So, we can say that a
Binary relationship exists when there are two types of entity and we call them a
degree of relationship is 2. Or in other words, in a relation when two entity sets are
participating then such type of relationship is known as a binary relationship. This is
the most used relationship and one can easily be converted into a relational table.
Example: We have two entity types ‘Student’ and ‘ID’ where each ‘Student’ has his
‘ID’. So, here two entity types are associating we can say it is a binary relationship.
Also, one ‘Student’ can have many ‘daughters’ but each ‘daughter’ should belong to
only one ‘father. We can say that it is a one-to-many binary relationship.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 25
Ternary (degree 3)
In the Ternary relationship, there are three types of entity associates. So, we can say
that a Ternary relationship exists when there are three types of entity and we call them
a degree of relationship is 3. Since the number of entities increases due to this, it
becomes very complex to turn E-R into a relational table. Now let’s understand with
the examples.
Example: We have three entity types ‘Teacher’, ‘Course’, and ‘Class’. The
relationship between these entities is defined as the teacher teaching a particular
course, also the teacher teaches a particular class. So, here three entity types are
associating we can say it is a ternary relationship.
N-ary (n degree)
In the N-ary relationship, there are n types of entity that associates. So, we can say
that an N-ary relationship exists when there are n types of entities. There is one
limitation of the N-ary relationship, as there are many entities so it is very hard to
convert into an entity, rational table. So, this is very uncommon, unlike binary which is
very much popular.
Example: We have 5 entities Teacher, Class, Location, Salary, Course. So, here five
entity types are associating we can say an n-ary relationship is 5.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 26
Mapping Cardinality
In the view of databases, cardinality refers to the uniqueness of data values that are
contained in a column. High cardinality is nothing but the column contains a large
percentage of totally unique values. Low cardinality is nothing but the column which has
a lot of “repeats” in its data range.
Cardinality between the tables can be of type one-to-one, many-to-one or many-to-
many.
Mapping Cardinality is expressed as the number of entities to which another entity can
be associated via a relationship set.
For binary relationship set there are entity set A and B then the mapping cardinality can
be one of the following −
One-to-one
One-to-many
Many-to-one
Many-to-many
One-to-one relationship
One entity of A is associated with one entity of B.
Example
Given below is an example of the one-to-one relationship in the mapping cardinality.
Here, one department has one head of the department (HOD).
One-to-many relationship
An entity set A is associated with any number of entities in B with a possibility of zero
and entity in B is associated with at most one entity in A
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 27
Example
Given below is an example of the one-to-many relationship in the mapping cardinality.
Here, one department has many faculties.
Many-to-one relationship
An entity set A is associated with at most one entity in B and an entity set in B can be
associated with any number of entities in A with a possibility of zero.
Example
Given below is an example of the many-to-one relationship in the mapping cardinality.
Here, many faculties work in one department.
Many-to-many relationship
Many entities of A are associated with many entities of B.
An entity in A is associated with many entities of B and an entity in B is associated with
many entities of A.
Many to many=many to one + one to many
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 28
Example
Given below is an example of the many-to-many relationship in the mapping cardinality.
Here, many employees work on many projects.
Keys in DBMS
A key refers to an attribute/a set of attributes that help us identify a row (or tuple)
uniquely in a table (or relation). A key is also used when we want to establish
relationships between the different columns and tables of a relational database.
o Keys play an important role in the relational database.
o It is used to uniquely identify any record or row of data from the table. It is also
used to establish and identify relationships between tables.
For example, ID is used as a key in the Student table because it is unique for each
student. In the PERSON table, passport_number, license_number, SSN are keys since
they are unique for each person.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 29
Types of keys:
1. Primary key
o It is the first key used to identify one and only one instance of an entity uniquely.
An entity can contain multiple keys, as we saw in the PERSON table. The key
which is most suitable from those lists becomes a primary key.
o In the EMPLOYEE table, ID can be the primary key since it is unique for each
employee. In the EMPLOYEE table, we can even select License_Number and
Passport_Number as primary keys since they are also unique.
o For each entity, the primary key selection is based on requirements and
developers.
2. Candidate key
o A candidate key is an attribute or set of attributes that can uniquely identify a
tuple.
o Except for the primary key, the remaining attributes are considered a candidate
key. The candidate keys are as strong as the primary key.
For example: In the EMPLOYEE table, id is best suited for the primary key. The rest of
the attributes, like SSN, Passport_Number, License_Number, etc., are considered a
candidate key.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 30
3. Super Key
Super key is an attribute set that can uniquely identify a tuple. A super key is a superset
of a candidate key.
4. Foreign key
o Foreign keys are the column of the table used to point to the primary key of
another table.
o Every employee works in a specific department in a company, and employee and
department are two different entities. So we can't store the department's
information in the employee table. That's why we link these two tables through
the primary key of one table.
o We add the primary key of the DEPARTMENT table, Department_Id, as a new
attribute in the EMPLOYEE table.
o In the EMPLOYEE table, Department_Id is the foreign key, and both the tables
are related.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 31
5. 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. In other words, the
total number of the alternate keys is the total number of candidate keys minus the
primary key. The alternate key may or may not exist. 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. In this relation, Employee_Id is chosen as the primary key, so the
other candidate key, PAN_No, acts as the Alternate key.
6. 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.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 32
Entity Relationship Diagram
ER Diagram stands for Entity Relationship Diagram, also known as ERD is a diagram
that displays the relationship of entity sets stored in a database. In other words, ER
diagrams help to explain the logical structure of databases. ER diagrams are created
based on three basic concepts: entities, attributes and relationships.
ER Diagrams contain different symbols that use rectangles to represent entities, ovals
to define attributes and diamond shapes to represent relationships.
At first look, an ER diagram looks very similar to the flowchart. However, ER Diagram
includes many specialized symbols, and its meanings make this model unique. The
purpose of ER Diagram is to represent the entity framework infrastructure.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 33
Lines: It links attributes to entity types and entity types with other relationship
types
Primary key: attributes are underlined
Double Ellipses: Represent multi-valued attributes
Components
ER diagram basically having three components:
Entities − It is a real-world thing which can be a person, place, or even a concept.
For Example: Department, Admin, Courses, Teachers, Students, Building, etc are
some of the entities of a School Management System.
Attributes − An entity which contains a real-world property called an attribute. For
Example: The entity employee has the property like employee id, salary, age, etc.
Relationship − Relationship tells how two attributes are related. For Example:
Employee works for a department.
ER Diagram Examples
For example, in a University database, we might have entities for Students, Courses,
and Lecturers. Students entity can have attributes like Rollno, Name, and DeptID. They
might have relationships with Courses and Lecturers.
Entity
A real-world thing either living or non-living that is easily recognizable and non
recognizable. It is anything in the enterprise that is to be represented in our database. It
may be a physical thing or simply a fact about the enterprise or an event that happens
in the real world.
An entity can be place, person, object, event or a concept, which stores data in the
database. The characteristics of entities are must have an attribute, and a unique key.
Every entity is made up of some ‘attributes’ which represent that entity.
Examples of entities:
Person: Employee, Student, Patient
Place: Store, Building
Object: Machine, product, and Car
Event: Sale, Registration, Renewal
Concept: Account, Course
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 34
Entity set:
An entity set is a group of similar kind of entities. It may contain entities with attribute
sharing similar values. Entities are represented by their properties, which also called
attributes. All attributes have their separate values. For example, a student entity may
have a name, age, class, as attributes.
Example of Entities:
A university may have some departments. All these departments employ various
lecturers and offer several programs.
An entity has a real-world property called attribute and these attributes are defined by a
set of values called domain.
Example 1
In a university,
A student is an entity,
University is the database,
Name and age and sex are the attributes.
The relationships among entities define the logical association between entities.
Example 2
Given below is another example of ER:
For example, Suppose we design a school database. In this database, the student will
be an entity with attributes like address, name, id, age, etc. The address can be another
entity with attributes like city, street name, pin code, etc and there will be a relationship
between them.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 36
Component of ER Diagram
1. Entity:
An entity may be any object, class, person or place. In the ER diagram, an entity can be
represented as rectangles.
Consider an organization as an example- manager, product, employee, department etc.
can be taken as an entity.
a. Weak Entity
An entity that depends on another entity called a weak entity. The weak entity doesn't
contain any key attribute of its own. The weak entity is represented by a double
rectangle.
2. Attribute
The attribute is used to describe the property of an entity. Eclipse is used to represent
an attribute.
For example, id, age, contact number, name, etc. can be attributes of a student.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 37
a. 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.
b. Composite Attribute
An attribute that composed of many other attributes is known as a composite attribute.
The composite attribute is represented by an ellipse, and those ellipses are connected
with an ellipse.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 38
c. Multivalued Attribute
An attribute can have more than one value. These attributes are known as a multivalued attribute. The
double oval is used to represent multivalued attribute.
For example, a student can have more than one phone number.
d. Derived Attribute
An attribute that can be derived from other attribute is known as a derived attribute. It
can be represented by a dashed ellipse.
For example, A person's age changes over time and can be derived from another
attribute like Date of birth.
3. Relationship
A relationship is used to describe the relation between entities. Diamond or rhombus is
used to represent the relationship.
For example, Scientist can invent many inventions, but the invention is done by the
only specific scientist.
c. Many-to-one relationship
When more than one instance of the entity on the left, and only one instance of an entity
on the right associates with the relationship then it is known as a many-to-one
relationship.
For example, Student enrolls for only one course, but a course can have many
students.
d. Many-to-many relationship
When more than one instance of the entity on the left, and more than one instance of an
entity on the right associates with the relationship then it is known as a many-to-many
relationship.
For example, Employee can assign by many projects and project can have many
employees.
Advantages of ER Model
Simple: Conceptually ER Model is very easy to build. If we know the relationship
between the attributes and the entities we can easily build the ER Diagram for the
model.
Effective Communication Tool : This model is used widely by the database
designers for communicating their ideas.
Easy Conversion to any Model : This model maps well to the relational model
and can be easily converted relational model by converting the ER model to the
table. This model can also be converted to any other model like network model,
hierarchical model etc.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 41
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.
What is an Entity, Entity Type and Entity Set?
Entity
An entity is a real-world thing which can be distinctly identified like a person, place or
a concept. It is an object which is distinguishable from others. If we cannot distinguish
it from others then it is an object but not an entity. An entity can be of two types:
Tangible Entity: Tangible Entities are those entities which exist in the real world
physically. Example: Person, car, etc.
Intangible Entity: Intangible Entities are those entities which exist only logically and
have no physical existence. Example: Bank Account, etc.
Note : In E-R model we don't represent the data but we represent the structure or schema.
When we convert E-R model to relational model then data can be stored in tuple or row and
hence, represented as an entity.
Entity Type
The entity type is a collection of the entity having similar attributes. In the above
Student table example, we have each row as an entity and they are having common
attributes i.e each row has its own value for attributes Roll_no, Age, Student_name
and Mobile_no. So, we can define the above STUDENT table as an entity type
because it is a collection of entities having the same attributes. So, an entity type in
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 42
an ER diagram is defined by a name(here, STUDENT) and a set of
attributes(here, Roll_no, Student_name, Age, Mobile_no). The table below shows
how the data of different entities( different students) are stored.
The E-R representation of the above Student Entity Type is done below.
Note: We use a rectangle to represent an entity type in the E-R diagram, not entity.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 43
Weak Entity Type : Weak entity type doesn't have a key attribute. Weak entity type
can't be identified on its own. It depends upon some other strong entity for its distinct
identity. This can be understood with a real-life example. There can be children only if
the parent exits. There can be no independent existence of children. There can be a
room only if building exits. There can be no independent existence of a room. A weak
entity is represented by a double outlined rectangle. The relationship between a weak
entity type and strong entity type is called an identifying relationship and shown with a
double outlined diamond instead of a single outlined diamond. This representation can
be seen in the diagram below.
Entity Set
Entity Set is a collection of entities of the same entity type. In the above example of
STUDENT entity type, a collection of entities from the Student entity type would form
an entity set. We can say that entity type is a superset of the entity set as all the
entities are included in the entity type. Let's try to understand this with the help of
an example.
Example 1: In the below example, two entities E1 (2, Angel, 19, 8709054568) and
E2(4, Analisa, 21, 9847852156) form an entity set.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 44
Example 2: We can form another entity set by taking three entities from the table. (2,
Angel, 19, 8709054568) , (3, Priya, 20, 9864257315) and (4, Analisa, 21,
9847852156) can also form a entity set. Similary, we can form any combination of the
entity set using any of the entities from the entity type 'STUDENT'. Also, we can
understand that if we take all the records to the entity set we get the entity type
'STUDENT'. So, we can say that the entity type is the superset of the entity set.
Enhanced ER models are advanced database diagrams that are very similar to regular
ER diagrams which represent the requirements and complexities of complex databases.
In a nutshell, it is a hybrid of ER models with some additional complexities.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 45
The Enhanced ER Diagram is a diagrammatic technique used to represent Enhanced
ER Models. They show Sub Class and Super Class, Specialization and Generalization,
Union or Category, Aggregation, and so on.
For Example, The following “sub-class” relationships. There are three types of
employees here: Secretary, Technician, and Engineer. Employee is the super-class of
the other three sets of individual sub-classes, each of which is a subset of the Employee
set.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 46
The Enhanced ER Model:
ER Models
An Entity-Relationship (ER) diagram is a visual representation of data based on the ER
model that describes how entities in the database are related to one another. It is most
commonly used in database or information system organizations.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 47
Whereas, Enhanced Entity-relationship (EER) Models are essentially expanded upon
ER Models. Enhanced ER models are useful tools for creating high-level models for
databases. With their improved features, you can plan databases more thoroughly by
delving deeper into the properties and constraints.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 48
An Enhanced ER diagram includes all of the elements of an ER diagram as well as the
following:
Inheritance of attributes or relationships
Categories or union types
Generalization and Specialization
Superclasses and Subclasses
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 49
1. Super Class
Super class is an entity type that has a relationship with one or more subtypes.
An entity cannot exist in database merely by being member of any super class.
For example: Shape super class is having sub groups as Square, Circle, Triangle.
2. Sub Class
Sub class is a group of entities with unique attributes.
Sub class inherits properties and attributes from its super class.
For example: Square, Circle, Triangle are the sub class of Shape super class.
Attribute Inheritance
When a subclass inherits from one or more superclasses, it inherits all their
attributes. In addition to the inherited attributes, a subclass can also define its own
specific attributes. A subclass also inherits participation in the relationship sets in which
its superclass (higher-level entity) participates.
Attribute Inheritance
The attributes of a higher level entity set are inherited through a lower level entity set
made by specialization-generalization hierarchy. Namely, all the attributes of the higher
level entity set are as well the attributes of the lower level entity set.
B. Specialization and Generalization
1. Generalization
Generalization is the process of generalizing the entities which contain the properties of
all the generalized entities.
It is a bottom approach, in which two lower level entities combine to form a higher level
entity.
Generalization is the reverse process of Specialization.
It defines a general entity type from a set of specialized entity type.
It minimizes the difference between the entities by identifying the common features.
For example:
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 50
In the above example, Tiger, Lion, Elephant can all be generalized as Animals.
2. Specialization
Specialization is a process that defines a group entities which is divided into sub
groups based on their characteristic.
It is a top down approach, in which one higher entity can be broken down into two lower
level entity.
It maximizes the difference between the members of an entity by identifying the unique
characteristic or attributes of each member.
It defines one or more sub class for the super class and also forms the
superclass/subclass relationship.
For example
D. Aggregation
Aggregation is a process that represents a relationship between a whole object and its
component parts.
It abstracts a relationship between objects and viewing the relationship as an object.
It is a process when two entities are treated as a single entity.
In the above example, the relation between College and Course is acting as an Entity in
Relation with Student.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 52