Entity-Relationship model or E R model is used to create a relationship between different attributes or entities. It describes the structure of the database with the help of the ER Diagram or Entity Relationship Diagram. ER model creates a simple design view of the data that makes the data easier to understand.
Example: Here, we have a database COMPANY, and in this database, EMPLOYEE is the entity (table). The employee entity contains several attributes like EMP_ID, EMP_NAME, EMP_ADDRESS, EMP_DATE_OF_BIRTH, EMP_AGE, and EMP_CONTACT.
ER Model Components
- Entity
- Entity Set
- Attributes
- Relation
1. Entity
The entity in DBMS can be a real-world object having conceptual reality and existence.
Example: In a COMPANY database, the entity type is EMPLOYEE. Here employees are real-world persons that have some existence.
Entity Types
Strong Entity
Entities that don’t depend on other entities. Contains a primary key. Represented by a single rectangular box.
Example: EMPLOYEE with EMP_ID as primary key.
Weak Entity
Entities that depend on parent entities. No primary key. Represented by double rectangular box.
Example: EMPLOYEE_ADDRESS depends on EMPLOYEE.
Tangible Entity
Entities with physical existence in the real world.
Example: Person, Table, Chair.
Intangible Entity
Entities without physical existence.
Example: Bank Account.
2. Entity Set
An entity set is a collection of more than one entity of a similar entity type.
Example: STUDENT is entity type, and (01, Sumit, 23), (02, Ajay 26), (03, Amit, 32) are the entity set.
3. Attributes
Attributes indicate the property and characteristics of an entity. Represented by elliptical shape.
Attribute Types
Simple Attribute
Cannot be further divided into subtypes. May contain null values.
Example: ID and ROLL_NO in STUDENT table.
Composite Attribute
Can be divided into meaningful subparts.
Example: NAME can be divided into FIRST_NAME, MIDDLE_NAME, LAST_NAME.
Single Valued
Can have only a single value.
Example: AGE in STUDENT table.
Multi-Valued
Contains more than one value at a time.
Example: ADDRESS in STUDENT table.
Derived Attribute
Value derived from other attributes.
Example: AGE derived from DATE_OF_BIRTH.
4. Relation
Shows relationships between entities. Represented by diamond shape in ER diagrams.
Relationship Types
One to One
One entity related to another single entity.
Example: Person to Voter ID card.
One to Many
One entity related to multiple entities.
Example: Customer to Orders.
Many to One
Multiple entities related to one entity.
Example: Students to School.
Many to Many
Multiple entities related to multiple entities.
Example: Students to Subjects.