E-R Diagram in DBMS
An Entity-Relationship model (ER
model) describes the structure of a database with the help of a diagram, which
is known as Entity Relationship Diagram. An ER is a design or blueprint of a
database that can later be implemented as a database. An ER diagram shows the
relationship among different entity sets.
It consists of three main
components:
i)
Entity
ii) Attributes
iii) Relationship
It is a GUI representation of the
logical structure widely used in database designing. It helps to identifying
the relationships between/among entities in a database.
Components of ER Diagram
ER Diagram has three main components: -
1. Entity: It is an object or component of a
data represented by a rectangle.
For example, in the above ER Diagram
there are two entities one is student and other is course.
There are two type of entities i.e.,
weak entity and strong entity
Weak Entity: An entity which cannot
be uniquely identifies or doesn't have it own key. It is dependent on
relationship with some other entity. It is represented by double rectangle. For
example, an apartment cannot exist without the building i.e., entity apartment
is dependent on the entity building.
Strong Entity and Weak Entity Example
There are basically four types of attributes:
i)
Key attribute: a key attribute
can uniquely identify a entity. text of key attribute is underlined. for
example, roll no. of a student can uniquely identifies a student from a class
of students.
ii)
Composite attribute: A composite attribute is a combination of different
attributes. for example, in entity student address is composed of state, city,
pin code, flat no.
iii) Multivalued attribute: An
attribute that can have multiple values is known as a multivalued attribute. It
is represented by a double oval. For example, a student can have multiple
addresses and multiple phone numbers.
iv) Derived attribute: an attribute
whose value can be derived from another attribute is known as a derived
attribute and represented by a dashed oval. for example, age of a student can
be derived from his date of birth.
3. Relationship :- It represents relation between/among
entities and represented by a diamond.
Cardinality : It defines the
numerical attributes of the relationship between two entities and entity sets.
There are four types of cardinalities:
i)
One to One Relationship: when a single instance of an entity is associated
with the single instance of another entity then it is known as one-to-one
relationship. For example, a person can hold only a single PAN card.
ii) One-to-many Relationship: when a single instance of an entity is associated with the multiple instances of another entity then it is known as one-to-many relationship. For example, A publisher can supply many books.
iii) Many to one Relationship: when
more than one instance of an entity is associated with the single instance of
another instance then it is known as Many to one Relationship. For example,
many students can enroll in a single course.
iv) Many to Many Relationships: when more than one instances of an entity is associated with more than one instances of other entity then it is known as many to many relationships. for example, a course can be assigned to many students and many students can take a single course(see the above example).
0 Comments