29 Jan 2020

  • January 29, 2020
  • Amitraj
Entity Relationship 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.





Entity Relationship Diagram (ER Diagram):-

An ER diagram shows the relationship among entity sets. An entity set is a group of similar entities and these entities can have attributes. 

An Entity Relationship Diagram (ERD) is a visual representation of different entities within a system and how they relate to each other. For example, the elements writer, novel, and a consumer may be described using ER diagrams the following way:




A Simple ER Diagram -






They are also known as ERD’s or ER models.




Components Of ER Diagram -









ER diagram has three main components:
1. Entity
2. Attribute
3. Relationship


1. Entity:-    An entity may be any object, class, person or place. In the ER diagram, an entity can be represented as rectangles.

-> Organization as an example- manager, product, employee, department etc. can be taken as an entity.







a)  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.







2. Attribute:-   The attribute is used to describe the property of an entity. Ellipse is used to represent an attribute.


For example, id, age, contact number, name, etc. can be attributes of a student.










a) Key Attribute:-   A key attribute can uniquely identify an entity from an entity set.
The key attribute is used to represent the main characteristics of an entity. It represents a primary key. The key attribute is represented by an ellipse with the text underlined.







b) Composite Attribute:-  An attribute that is a combination of other attributes is known as composite attribute.

The composite attribute is represented by an ellipse, and those ellipses are connected with an ellipse.







c) Multivalued Attribute:-    An attribute that can hold multiple values is known as multivalued attribute.The double oval is used to represent multivalued attribute.

For example, a student can have more than one phone number.






d) Derived Attribute:-   A derived attribute is one whose value is dynamic and derived from another attribute. It is represented by dashed ellipse in an ER Diagram.

For example, A person's age changes over time and can be derived from another attribute like Date of birth.










3. Relationship:-
A relationship is represented by diamond shape in ER diagram, it shows the relationship among entities. 





-> There are three types of relationship that exist between Entities.

1. Binary Relationship
2. Recursive Relationship
3. Ternary Relationship




1. Binary Relationship:-

Binary Relationship means relation between two Entities. 

-> There are four types of binary relationships:

a) One to One
b) One to Many
c) Many to One
d) Many to Many





a) One to One Relationship :-
When a single instance of an entity is associated with a single instance of another entity then it is called one to one relationship.

For example, A female can marry to one male, and a male can marry to one female.










b) One to Many Relationship :-  
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, Scientist can invent many inventions, but the invention is done by the only specific scientist.









c) Many to One Relationship :-   
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, Student enrolls for only one course, but a course can have many students.








d) Many to Many Relationship:-
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, Employee can assign by many projects and project can have many employees.











2. Recursive Relationship:-
When an Entity is related with itself it is known as Recursive Relationship.







3. Ternary Relationship:-
Relationship of degree three is called Ternary relationship.

A Ternary relationship involves three entities. In such relationships we always consider two entites together and then look upon the third.



For example, in the diagram above, we have three related entities, Company, Product and Sector. To understand the relationship better or to define rules around the model, we should relate two entities and then derive the third one.

-> A Company produces many Products/ each product is produced by exactly one company.

-> A Company operates in only one Sector / each sector has many companies operating in it.

-> Considering the above two rules or relationships, we see that although the complete relationship involves three entities, but we are looking at two entities at a time.












Translate

Popular Posts