An ER Diagram consists of the following components:
An entity may be an object, place, person, or an event which stores data in the database. In an entity-relationship diagram, an entity is represented by a rectangle. Student, course, manager, employee, patient, etc. are examples of an entity.
Entity type: An entity type is a collection or a set of entities having some common attributes. In a database, each entity type is described by a name and list of attributes.
Entity set: It is a set (or collection) of entities of the same type which share the similar properties, or attributes.
For example,the group of people who are lecturers in a university can be deﬁned as an entity set lecturer. Similarly, the entity set of students might represent the group of all students in the university.
An entity can be characterized into two types:
- Strong entity: This type of entity has a primary key attribute which uniquely identifies each record in a table. In the ER diagram, a strong entity is usually represented by a single rectangle.
- Weak entity:An entity does not have a primary key attribute and depends on another strong entity via foreign key attribute. In the ER diagram, a weak entity is usually represented by a double rectangle.
2. Attributes: An attribute in an Entity-Relationship Model describes the properties or characteristics of an entity. It is represented by an oval or ellipse shape in the ER diagram. Every oval shape represents one attribute and is directly connected to its entity which is in the rectangle in shape.
For example, employee_id, employe_name, Gender, employee_age, Salary, and Mobile no. are the attributes which define entity type Employee.
In the ER model, an attribute can be characterized into the following types:
- Simple attribute: An attribute which contains an atomic value and cannot be divided further is called a simple attribute.For example, Gender and Salary of a person. It is also represented by an oval.
- Key attribute: An attribute which can uniquely identify an entity in an entity set is called a key attribute. It represents a primary key in the ER diagram. In an Entity-Relationship diagram, the key attribute is denoted by an oval with an underlying line. For example, employee_id will be unique for each employee.
- Composite attribute:An attribute which is a combination of two or more simple attributes is called a composite attribute. In an Entity-Relationship diagram, it is represented by an ellipse, and that ellipse comprises of other ellipses.For example, the Name attribute of an employee entity type consists of First name, Second name, and Last name.
- Derived attribute: An attribute which can be derived from other attributes is called a derived attribute. In an entity-relationship diagram, these attributes are represented by a dashed oval shape. For example, employee_age is a derived attribute as it changes over time and can be derived from another attribute DOB (Date of birth).
- Multi-valued attribute: An attribute which contains more than one value for a given entity. For example, an employee can have more than one mobile number and email address.
A relationship in Entity-Relationship Model is used to describe the relation between two or more entities. It is represented by a diamond shape in the ER diagram. For example, student study in college, employee works in a department. Here, ‘study in’ and ‘works in’ are the relationships.
Degree of Relationship
A relationship where a number of different entity set participate is called as degree of a relationship.
Degree of relationship can be categorized into the following types:
- Unary Relationship
- Binary Relationship
- Ternary Relationship
- n-ary Relationship
- Unary Relationship: A relationship where a single entity set participates is called as a unary relationship. For example, In a company, an employee manages or supervises another employee.
- Binary Relationship: When two entity set participates in a relationship is called a binary relationship.
It is further categorized into four types:
- One-to-One Relationship: When one entity from an entity set A is associated with another entity of entity set B and vice versa. Such type of relationship is called one to one relationship.
- One-to-Many Relationship:When one entity from an entity set A is associated or linked with multiple entities of entity set B, then it is called a one-to-many relationship.
- Many-to-One Relationship: When more than one entities from an entity set A is associated with one entity of entity set B, then it is called a many-to-one relationship.
- Many-to-Many Relationship: When more than one entity from an entity set A is associated with many entity of an entity set B. Such types of relationship are called a many-to-many relationship.
c) Ternary Relationship: When three entity set participates in a relationship, is called a ternary relationship.
d) n-ary Relationship: When more than three entity set involves in a relationship is called an n-ary relationship.
- DBMS View: Read, Update, Create and Drop
- Hashing in DBMS: Static and Dynamic
- View Serializability in DBMS
- Conflict Serializability in DBMS
- Concurrent Execution of Transaction
- Normalization in DBMS: 1NF, 2NF, 3NF, BCNF & 4NF with Examples
- DBMS Joins: Inner, Outer, Natural and Self Join
- Conversion of ER Diagram into Relational Model
- DBMS Keys: Primary, Super, Candidate, Foreign
- DBMS Generalization, Specialization, and Aggregation