ER PartA
ER PartA
An Entity Relationship Diagram (ERD) also referred to as Entity Relationship (ER) model. This
model illustrates how entities such as people, objects, etc. relate to each other in a system. ERD
is a high level data model used to develop the conceptual design for the database.
In ER modeling, the database structure is portrayed as an entity-relationship 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.
b. Strong entity
A strong entity is an entity that is not dependent on any other entity. It has a primary key, or a table
includes a primary key.
The connection between two strong entities is The connection between a weak and a strong
4
shown by a sole diamond. entity is shown by a dual diamond.
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.
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.
c. Multivalued Attribute
An attribute can have more than one value. These attributes are known as a multi-valued
attribute. The double oval is used to represent multi-valued 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.
In simpler words, a relationship is defined as an association among several entities. ‘Enrolled in’
is a relationship that exists between entities Student and Course in the following illustration
A relationship set is a set of relationships of same type. Example: Set representation of above ER
diagram is-
b. Binary relationships
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.
I. One-to-One Relationship
When only one instance of an entity is associated with the relationship, then it is known as one to
one relationship. For example, when a single instance of an entity is associated with a single
instance of another entity then it is called one to one relationship. For example, a person has only
one passport and a passport is given to one person.
1 1
ASSIGNED
PERSON PASSPORT
II. One-to-many relationship
When only one instance of the entity on the left, and more than one instance of an entity on the
right associates with the relationship then this is known as a one-to-many relationship. For
example, Scientist can invent many inventions, but the invention is done by the only specific
scientist.
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.
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.
c. 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.
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.
d. 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.
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.