Introduction to ER Models
The Entity-Relationship Model (ER Model) is a conceptual model for designing a
databases. This model represents the logical structure of a database, including
entities, their attributes and relationships between them.
Entity: An objects that is stored as data such as Student, Course or Company.
Attribute: Properties that describes an entity such as StudentID, CourseName,
or EmployeeEmail.
Relationship: A connection between entities such as "a Student enrolls in
a Course".
Why Use ER Diagrams In DBMS?
• ER diagrams represent the E-R model in a database, making them
easy to convert into relations (tables).
• These diagrams serve the purpose of real-world modeling of objects
which makes them intently useful.
• Unlike technical schemas, ER diagrams require no technical
knowledge of the underlying DBMS used.
• They visually model data and its relationships, making complex
systems easier to understand.
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, such as a student's
multiple phone numbers
• Double Rectangle: Represents weak entities, which depend on other entities for
identification.
What is an
Entity?
• An Entity represents a real-world object, concept or thing about
which data is stored in a database. It act as a building block of a
database. Tables in relational database represent these entities.
• Example of entities:
• Real-World Objects: Person, Car, Employee etc.
• Concepts: Course, Event, Reservation etc.
• Things: Product, Document, Device etc.
• The entity type defines the structure of an entity, while individual
instances of that type represent specific entities.
What is an Entity Set?
• An entity refers to an individual object of an entity type, and the
collection of all entities of a particular type is called an entity set. For
example, E1 is an entity that belongs to the entity type "Student," and
the group of all students forms the entity set.
• We can represent the entity sets in an ER Diagram but we can't
represent individual entities because an entity is like a row in a table,
and an ER diagram shows the structure and relationships of data, not
specific data entries (like rows and columns). An ER diagram is a visual
representation of the data model, not the actual data itself.
Types of Entity
There are two main types of entities:
1. Strong Entity
• A Strong Entity is a type of entity that has a key Attribute that can uniquely
identify each instance of the entity. A Strong Entity does not depend on any
other Entity in the Schema for its identification. It has a primary key that
ensures its uniqueness and is represented by a rectangle in an ER diagram.
2. Weak Entity
• A Weak Entity cannot be uniquely identified by its own attributes alone. It
depends on a strong entity to be identified. A weak entity is associated with an
identifying entity (strong entity), which helps in its identification. A weak entity
are 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.
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.
Attributes in ER Model
In DBMS, an attribute is a characteristic of an entity that is used to
describe an entity. Essentially, it is a column in a table that holds data
values. An entity may contain any number of attributes. One of the
attributes is considered as the primary key. In an Entity-Relation model,
attributes are represented in an elliptical shape.
Example: Student has attributes like name, age, roll number, and many
more. To uniquely identify the student, we use the primary key as a roll
number.
Types of Attributes
There are different types of attributes as discussed below-
• Simple Attribute
• Composite Attribute
• Single-Valued Attribute
• Multi-Valued Attribute
• Derived Attribute
• Complex Attribute
• Stored Attribute
• Key Attribute
• Null Attribute
• Descriptive Attribute
1. Simple Attribute
• An attribute that cannot be further subdivided into components is a
simple attribute.
• Example: The roll number of a student, the ID number of an
employee, gender, and many more.
2. Composite Attribute
An attribute that can be split into components is a composite attribute.
• Example: The address can be further split into house number, street
number, city, state, country, and pin code, the name can also be split
into first name middle name, and last name.
3. Single-Valued Attribute
• The attribute which takes up only a single value for each entity
instance is a single-valued attribute.
• Example: The age of a student, Aadhar card number.
4. Multi-Valued Attribute
The attribute which takes up more than a single value for each entity
instance is a multi-valued attribute. And it is represented by double
oval shape.
• Example: Phone number of a student: Landline and mobile.
5. Stored Attribute
• The stored attribute are those attribute which doesn't require any
type of further update since they are stored in the database.
• Example: DOB(Date of birth) is the stored attribute.
6. Derived Attribute
• An attribute that can be derived from other attributes is derived
attributes. And it is represented by dotted oval shape.
• Example: Total and average marks of a student, age of an employee
that is derived from date of birth.
7. Complex Attribute
• Those attributes, which can be formed by the nesting of composite
and multi-valued attributes, are called "Complex Attributes". These
attributes are rarely used in DBMS(DataBase Management System).
That's why they are not so popular.
• Example: Address because address contain composite value like
street, city, state, PIN code and also multivalued because one people
has more that one house address.
8. 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 an underline.
It is essential to understand that a NULL value differs from a zero or an empty string. A NULL value represents missing or undefined data.
It is essential to understand that a NULL value differs from a zero or an empty string. A NULL value represents missing or undefined data.
9. Null
It is essential to understand that a NULL value differs from a zero or an empty string. A NULL value represents missing or undefined data.
Attribute
This attribute can take NULL value when entity does not have value
for it.
• Example: The 'Net Banking Active Bin' attribute gives weather
particular customer having net banking facility activated or not
activated.
• For bank which does not offer facility of net banking in customer table
'Net Banking Active Bin' attribute is always null till Net banking facility
is not activated as this attribute indicates Bank offers net banking
facility or does not offers.
• NOTE:- a null value is differs from a zero or an empty string. a null
value represents missing or undefined data.
10. Descriptive Attribute
• Descriptive attribute give information about the relationship set
example given below. Here Start Date is the descriptive attribute of
Manages relationship.
NOTE:-Relationship set in a Database Management System (DBMS) is
essential as it provides the ability to store, recover, and oversee endless
sums of information effectively in cutting-edge data administration,
hence making a difference in organizations.
In a Relational database, relationship sets are built up by utilizing keys,
such as primary and foreign keys, to interface related records over
distinctive tables.
Types of Relationship
in Database
• A relationship in a DBMS exists when a variable has a connection with
the properties stored in different tables. Such relationships help the
organization of entities intertwined with each other, ultimately
enabling efficient data processing. They're exhibited usually via keys in
a table, which is either columns or fields that specify a distinctive
arrangement for each record.
• For example, one can think of the university database. Students,
courses, and instructors, variably, might become tables. The
relationship between the two tables is that courses indicate which
courses the student can enroll in. Database management facilitates
the reliable data apostrophe and performance of complex operations
due to the fact that it guarantees the quality and identity of the data.
1. One-to-One (1:1) Relationship
• In one to one relationships, a record is present in one table along with
its corresponding existing relation, and the vacant relation among the
records is present in another table. The type of relationship we are
talking about is not as usual, and it is normally used when two entities
that belong to a specific set need to be stored independently for
normalization or security purposes. In another case, a person's
employees' data consists of a record in the "personal details" table in
a human resources database.
2. One-to-Many (1:N) Relationship
• A relationship where the items from one table can be linked to only
one or many items from another table is called a one-to-many
relationship; in some cases, one item from the first table correlates
with only one item from the second table. This connection becomes
very strong in that it is particularly used to describe situations where
one object can be linked to many similar or identical objects. For
example, in an online store backend database, every customer may
place multiple orders, yet the master customer record stays the same.
If a record has more than one order, these are obtained from the
backend database.
3. Many-to-Many (N:M) Relationship
• The duality of a many-to-many relationship is characterized by the
presence of multiple records belonging to a table in association with
multiple records from another table. The interconnection of these
relationships follows a junction table format, which is the component
that holds both tables together. In the many-to-many relationship
model, a wide variety of complex relationships can be established
where each entity has many related entities. Such a database for a
music streaming service could have a table representing each track
that belongs to multiple playlists, and each of them could contain
multiple tracks.
Why are Relationships Important in a Database?
Relationships are crucial in a database for several reasons:
• Data Integrity: The relationships make the necessary links between data sets and ensure that
information kept and joined together is accurate. In this way, the consistency and correctness
of the data are maintained.
• Efficient Data Retrieval: The relationship permits the complete search of data among multiple
tables, storing fewer inputs and executing the query quickly, respectively.
• Normalization: Relations remain priorities that ensure the sync of data and achieving a level
of relevance.\
• Complex Data Analysis: Relationships empower users for state-of-the-art querying,
aggregation, and analysis; thereby, users would be deriving meaningful insights from their
data.
• Scalability: It has turned out that well-defined relationships, in their turn, are the key issue
that helps the database to be scalable, thus having a structure that is easy to manage and
could be further adapted to possible expanding business needs.