An Entity Relationship Diagram (ERD) is a graphical representation of entities and their relationships to each other. It is a data modeling technique that graphically illustrates an information system’s entities and the relationships between those entities. An ERD is a conceptual and representational model of data used to represent the entity framework infrastructure.
The elements of an ERD are:
An entity is a real-world item or concept that exists on its own. Entities are equivalent to database tables in a relational database, with each row of the table representing an instance of that entity. Entities are of following types:
A relationship is how the data is shared between entities. There are three types of relationships between entities:
- One to One:One instance of an entity (A) is associated with one other instance of another entity (B)
- One to Many:One instance of an entity (A) is associated with zero, one or many instances of another entity (B), but for one instance of entity B there is only one instance of entity A.
- Many to Many:One instance of an entity (A) is associated with one, zero or many instances of another entity (B), and one instance of entity B is associated with one, zero or many instances of entity (A).
An attribute of an entity is a particular property that describes the entity. Attributes are of following types:
1. Key or Non-Key Attributes:An entity usually has an attribute whose values are distinct for each individual entity. This attribute uniquely identifies the individual entity. Such an attribute is called a key attribute. For example, in the Employee entity type, EmpNo is the key attribute since no two employees can have same employee number.
- Simple and Composite Attributes:Composite attributes can be divided into smaller subparts. These subparts represent basic attributes with independent meanings of their own. For example, take Name attributes. We can divide it into sub-parts like First_name, Middle_name, and Last_name. Attributes that can’t be divided into subparts are called Simple or Atomic attributes. For example, EmployeeNumber is a simple attribute.
- Stored and Derived Attributes:There may be a case when two or more attributes values are related. Take the example of age. Age of a person can be calculated from person’s date of birth and present date. Difference between the two gives the value of age. In this case, age is the derived attribute. The attribute from which another attribute value is derived is called stored attribute. In the above example, date of birth is the stored attribute.
Steps involved in creating an ERD include:
- Identifying and defining the entities
- Determining all interactions (relationships) between the entities
- Analyzing the nature of interactions/determining the cardinality of the relationships
- Creating the ERD