Software engineering
Software engineering
ER diagram
ER-modeling is a data modeling method used in software engineering to produce a conceptual data
model of an information system. Diagrams created using this ER-modeling method are called Entity-
Relationship Diagrams or ER diagrams or ERDs.
Purpose of ERD
The database analyst gains a better understanding of the data to be contained in the database through
the step of constructing the ERD.
Finally, the ERD is used to connect the logical structure of the database to users. In particular, the ERD
effectively communicates the logic of the database to users.
ER Model is used to model the logical view of the system from a data perspective which consists of these
symbols:
Lines: Lines represent attributes to entities and entity sets with other relationship types.
ER Model consists of Entities, Attributes, and Relationships among Entities in a Database System.
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.
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:
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.
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.
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.
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.
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.
3. Relationships
The association among entities is known as relationship. Relationships are represented by the diamond-
shaped box. For example, an employee works_at a department, a student enrolls in a course. Here,
Works_at and Enrolls are called relationships.
Types of Cardinalities
1. One to One: One entity from entity set A can be contained with at most one entity of entity set B and
vice versa. Let us assume that each student has only one student ID, and each student ID is assigned to
only one person. So, the relationship will be one to one.
2. One to many: When a single instance of an entity is associated with more than one instances of
another entity then it is called one to many relationships. For example, a client can place many orders; a
order cannot be placed by many customers.
3. Many to One: More than one entity 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. For example - many students can study in a single college, but a student cannot study in many
colleges at the same time.
4. Many to Many: One entity from A can be associated with more than one entity from B and vice-versa.
For example, the student can be assigned to many projects, and a project can be assigned to many
students.