Entity relationship model
What is entity relationship model?
Components of ER Diagram
- Entity: Any real world objects came under the category of entity. Entity can be any person, any object, any place or any event, relevant for a given database system.
- Attribute They are the properties through which an entity is defined. Suppose there is an entity called Student, then Student’s name, Student’s age, Student’s email address, Student’s phone number came under the category of attribute of the entity “Student”
- Simple attribute: Attribute whose values are already atomic & cannot be divided further.For Example The first name & last name of an entity “Student”.
- Composite attribute : Attributes which are made up of more than one simple attributes. For Example The attribute ‘Name’ which contains First Name, Middle name and last name etc.
- Single valued attribute: These attributes contain only single values. For Example The attribute “Age” of an entity “Student”
- Multi valued attribute: These attributes contain multiple values. T is represented by double oval.For Example ‘Phone Number’ of an entity “Student”
- Derived attribute: The attributes which are derived from other attributes & are not present in the database system are known to be called as Derived Attributes. For example The ‘Age’ of the entity ‘Student’ can be derived from the attribute “Date of Birth”. So age is the derived attribute. Derived attribute is represented by dotted oval.
ER Diagram Notations and Symbols
Different er diagram notations and symbols are shown in following figure
Relationships between entities
- ONE TO ONE
An entity in an entity set A can be associated with at-most one entity in other entity set B or an entity in set B can be associated with at most one entity in set A.
Example : One student can enroll in at-most one course or one course can be enrolled by at most one student.
- ONE TO MANY
When an instance or entity of an entity set A is associated with any number(zero or many) entities in other entity set B or an entity in entity set B is associated with at-most one entity in entity set A. then it is known as one to many to one relationship. Mainly ‘Many’ or ‘N’ should be in the right side of the relationship.
Example: One student can enroll in any number of course ( including zero) or one course can be enrolled by at most one student.
- MANY TO ONE
When an entity or instance of an entity set A is associated with at most one entity in other entity set B or an entity in entity set B can be associated with any number of entities of entity set A then it is known as one to many relationship. Mainly ‘Many’ or ‘N’ should be in the left side of the relationship.
Example : One student can enrolled in at most one course or one course can be enrolled by any( zero or many) students.
- MANY TO MANY
When an entity in an entity set A is associated with any number of entities in an entity set B and vice versa then this type of cardinality or mapping is known as many to many. Mainly ‘Many’ or ‘N’ should be in the both side of the relationship.
Example: One student can enroll in any number of course ( zero or many ) or one course can be enrolled by any( zero or many ) number of students.
ER Diagram Example with solution
An ER diagram for Customer and Loan entity is as shown in following figure.
Relationship between customer and loan entity set is borrower. It means customer borrow the loan. Different attributes of customer and loan entity are also shown.
Customer_id is the key attribute of Customer entity similarly loan_id is the key attribute of loan entity.
ER Diagram Keys
- Primary key: It is that column of a table which has all the unique values inside it. Through primary key, the data in the table will be identified uniquely.
- Composite key
Participation constraints in ER Diagram
Total Participation
In total participation each entity is involved in the relationship. Total participation is represented by double lines in ER diagram. Total participation specifies that each entity in the entity set must compulsorily participate in at least one relationship instance the relationship set.
Partial participation
That is why, it is sometime also known as optional participation
Partial Participation Example
Also Read : Blockchain’s Battle with Financial Inclusion — Part 1