ER model or entity relationship is a database model used for the design and representation of relationships between data. It develops a very simple and easy to design view of data. The database structure is shown as a diagram called an entity-relationship diagram.Components of ER diagram include Entities,attributes,Keys and Relationships.
Entity and Entity Set
Entity signifies a real-world object that holds some properties and relationships.A student can be called as an entity and all the information about that student is called as an Entity set.
The attribute is used to describe the property of an entity.Foe example the name,roll no are called as attributes of a entity student in a database.
- Simple attribute: The attributes with values that are unique or atomic and cannot be broken down further are simple attributes. For example, a student’s age.
- Composite attribute: A composite attribute is made up of more than one simple attribute. For example, the student’s first name, second name, third name.
- Derived attribute: These are the attributes that are not present in the whole database management system but are derived using other attributes. For example, the average age of students in a class. It can be represented by a dashed ellipse.
- Single-valued attribute: They have a single value.
- Multi-valued attribute: They can have multiple values.
Keys are used to uniquely identify any record or row of data from the table. It is also used to establish and identify relationships between tables.A Key can be a single attribute or a group of attributes, where the combination may act as a key.
Following are the types of Keys:
- Super Key
- Candidate Key
- Primary Key
- Primary key-It is a key that can uniquely identify each record in a table. It is also included as a candidate key.
- Candidate Key-It is an attribute or a set of attributes that can act as a Primary Key for a table to uniquely identify each record in that table.
- Super Key-Super Key is defined as a set of attributes within a table that can uniquely identify each record within a table. Super Key is a superset of the Candidate key.
- Generalization is like a bottom-up approach in which two or more entities of lower-level combine to form a higher-level entity if they have some attributes in common.
- In general, an entity of a higher level can also combine with the entities of the lower level to form a higher-level entity.
- Generalization is more like a subclass and superclass system,but it uses a different approach. Generalization uses the bottom-up approach.
- In generalization, entities are combined to form a more generalized entity.
For example, Faculty and Student entities can be generalized and create a higher level entity Person.
- Specialization is a top-down approach, and it is the opposite of Generalization. In specialization, one higher-level entity can be broken down into two lower-level entities.
- Specialization is used to identify the subset of an entity set that shares some different or some unique features.
For example: In an Employee management system, EMPLOYEE entity can be specialized as TESTER or DEVELOPER or MTS based on what role they play in the company.
Aggregration is a process when relation between two entities is treated as a single entity.
Any two entities can have a relationship between them.The degree of relationship can be defined as the number of occurrences in one entity that is associated with the number of occurrences in another entity.
There is the three degree of relationship:
- One-to-one (1:1)
- One-to-many (1:M)
- Many-to-many (M:N)
The Relationship is defined as an association among two or more entities.
This model is based on the real world. It contains necessary objects (known as entities) and the relationship among these objects.
Entity type typically corresponds to one or several related tables in the database.