DBMS_Introduction of ER Model
DBMS_Introduction of ER Model
ER Model is used to model the logical view of the system from a data
perspective which consists of these symbols:
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?
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
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 .
What is Attributes?
Attributes are the properties that define the entity type. For example,
Roll_No, Name, DOB, Age, Address, and Mobile_No are the attributes
that define entity type Student. In ER diagram, the attribute is
represented by an oval.
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
Entity-Relationship Set
Unary Relationship
Binary Relationship
3. Ternary Relationship: When there are three entity sets participating in
a relationship, the relationship is called a ternary relationship.
What is Cardinality?
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.
3. Many-to-One: When entities in one entity set can take part only once
in the relationship set and entities in other entity sets can take part more
than once in the relationship set, cardinality is many to one. Let us
assume that a student can take only one course but one course can be
taken by many students. So the cardinality will be n to 1. It means that
for one course there can be n students but for one student, there will be
only one course.
In this case, each student is taking only 1 course but 1 course has been
taken by many students.
4. Many-to-Many: When entities in all entity sets can take part more than
once in the relationship cardinality is many to many. Let us assume that
a student can take more than one course and one course can be taken
by many students. So the relationship will be many to many.
Participation Constraint
Participation Constraint is applied to the entity participating in the
relationship set.
2. Partial Participation – The entity in the entity set may or may NOT
participate in the relationship. If some courses are not enrolled by any of
the students, the participation in the course will be partial.
The diagram depicts the ‘Enrolled in’ relationship set with Student Entity
set having total participation and Course Entity set having partial
participation.
Determine the main objects you want to represent in the database. Eg,
“students”, “courses”, or “products”.
Create relationships between entities to specify how entities interact with each
other. Relationships are verbs like “teaches”, “studies”, or “sells”.
Organize all entities and relationships in a clean way for better readibility and
understanding.
After learning the steps of how to draw an enitity relationship diagram, we will
create a demo ER diagram.
Let’s take an example of ER diagram for a bank through which we can learn
how to design an ER and understand all the required methods.
Defining Entities
Adding Attributes
Attributes are the kind of properties that describe the entities. They are
represented by ovals.
Establishing Relationships
Entities have some relationships with each other. Relationships define how
entities are associated with each other.
Specifying Cardinality
In the entity relationship diagram, the one to one relationship means that
single entity in one table is associated with single entity in another table.
For example, one driver have only one license.
3. Many to One(N:1)
ER Diagram
Primary keys are the unique identifier for each record in database table. It is
denoted by an underline under the attribute name.
The below diagram is our final entity relationship diagram for bank with all
entities, their attributes and the relationship between them with the
PRIMARY KEY and Cardinality ratio.
Final ER Diagram
Benefits of an ER Diagram