Entity-Relationship (ER) Data 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:
- entity set
- relationship set.
- An ER diagram shows the relationship among entity sets.
- model for identifying entities to be represented in the database and representation of how those entities are related.
- ER models are used to model real-world objects like a person, a car, or a company
- relation between these real-world objects.
- In short, the ER Diagram is the structural format of the database.
Symbols Used in ER Model
- Rectangles: Rectangles represent Entities in the ER Model.
- Ellipses: Ellipses represent Attributes in the ER Model.
- Diamond: Diamonds represent Relationships among Entities.
- Lines: Lines represent attributes to entities and entity sets with other relationship types.
- Double Ellipse: Double Ellipses represent Multi-Valued Attributes .
- Double Rectangle: Double Rectangle represents a Weak Entity.
]
Components of a ER Diagram
1. 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 represented as rectangle in an ER diagram.
- Consider an organization as an example- manager, prodct, employee, department etc. can be taken as an entity.
- 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.
2. 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.
- For Example, A company may store the information of dependents (Parents, Children, Spouse) of an Employee. But the dependents don’t have existed without the employee. So Dependent will be a Weak Entity Type and Employee will be Identifying Entity type for Dependent, which means it is Strong Entity Type.
3. Attribute and types
- An attribute describes the property of an entity.
- 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.
There are four types of attributes:
- 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.
- Composite Attribute
- An attribute composed of many other attributes is called a composite attribute.
- An attribute that is a combination of other attributes is known as composite attribute.
- For example, In student entity, the student address is a composite attribute as an address is composed of other attributes such as pin code, state, country.
- Multivalued Attribute
- An attribute consisting of more than one value for a given entity.
- An attribute that can hold multiple values is known as multivalued attribute.
- It is represented with double ovals in an ER Diagram.
- For example – A person can have more than one phone numbers so the phone number attribute is multivalued.
- derived attribute
- its an attribute that can be derive from an existing attribute
- for example, we can derive the age attribute from the Date of birth of the entity.
4. Relationships
- one to one e.g a person can have only one passport
- one to many e.g each customer can place multiple orders, but each order is associated with only one customer.
- many to many e.g a customer can buy many products and a product can have multiple customers
- many to one e.g