ER-Diagram is a visual representation of data that describes how data is related to each other.
The E-R diagram has three main components.
An Entity can be any object, place, person or class. In E-R Diagram, an entity is represented using rectangles. Consider an example of an Organisation. Employee, Manager, Department, Product and many more can be taken as entities from an Organisation.
Weak entity is an entity that depends on another entity. Weak entity doen't have key attribute of their own. Double rectangle represents weak entity.
An Attribute describes a property or characterstic of an entity. For example, Name, Age, Address etc can be attributes of a Student. An attribute is represented using eclipse.
Key attribute represents the main characterstic of an Entity. It is used to represent Primary key. Ellipse with underlying lines represent Key Attribute.
An attribute can also have their own attributes. These attributes are known as Composite attribute.
A Relationship describes relations between entities. Relationship is represented using diamonds.
There are three types of relationship that exist between Entities.
Binary Relationship means relation between two Entities. This is further divided into three types.
The above example describes that one student can enroll only for one course and a course will also have only one Student. This is not what you will usually see in relationship.
The arrows in the diagram describes that one student can enroll for only one course.
The above diagram represents that many students can enroll for more than one courses.
When an Entity is related with itself it is known as Recursive Relationship.
Relationship of degree three is called Ternary relationship.