5.1 Data Models - ER Model
5.1 Data Models - ER Model
1. E-R Model
2. Object oriented Model
3. Relational Model
4. Hierarchical Model
5. Network Model
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 (ER Diagram). An ER
model is a design or blueprint of a database that can later be implemented as a
database. The main components of E-R model are: entity set and relationship set.
In the following diagram we have two entities -Student and College and their
relationship. The relationship between Student and College is many to one as a college
can have many students however a student cannot study in multiple colleges at the same
time. Student entity has attributes such as Stu_Id, Stu_Name & Stu_Addr and College
entity has attributes such as Col_ID & Col_Name.
Symbols in ER Diagram:
1. Entity
Any real-world object can be represented as an entity about which data can be stored in a
database. All the real world objects like a book, an organization, a product, a car, a
person are the examples of an entity. An entity is an object or component of data. An
entity is represented as rectangle in an ER diagram. For example: In the following ER
diagram we have two entities Student and College and these two entities have many to
one relationship as many students study in a single college. We will read more about
relationships later, for now focus on entities.
Weak Entity:
An entity that cannot be uniquely identified by its own attributes and relies on the
relationship with other entity is called weak entity. The weak entity is represented by a
double rectangle. For example – a bank account cannot be uniquely identified without
knowing the bank to which the account belongs, so bank account is a weak entity.
2. Attribute
1. Key attribute
2. Composite attribute
3. Multivalued attribute
4. Derived attribute
1. Key attribute:
A key attribute can uniquely identify an entity from an entity set. For example, student
roll number can uniquely identify a student from a set of students. Key attribute is
represented by oval same as other attributes however the text of key attribute is
underlined.
2. Composite attribute:
3. Multivalued attribute:
4. Derived attribute:
A derived attribute is one whose value is dynamic and derived from another attribute. It is
represented by dashed oval in an ER Diagram. For example – Person age is a derived
attribute as it changes over time and can be derived from another attribute (Date of birth).
When a single instance of an entity is associated with a single instance of another entity
then it is called one to one relationship. In other words, One entity from entity set X can
be associated with at most one entity of entity set Y and vice versa.
For example1., a person has only one passport and a passport is given to one person.
When a single instance of an entity is associated with more than one instances of another
entity then it is called one to many relationship.
For example – a customer can place many orders but a order cannot be placed by many
customers.
When more than one instances of an entity is associated with a single instance of another
entity then it is called many to one relationship. For example – many students can study
in a single college but a student cannot study in many colleges at the same time.
When more than one instances of an entity is associated with more than one instances of
another entity then it is called many to many relationship. For example, a can be assigned
to many projects and a project can be assigned to many students.
For example, Students as a group are associated with multiple faculty members, and
faculty members can be associated with multiple students.
4. Cardinality in ER Diagram
Examples