Entity-Relationship(ER) Model

Entity-Relationship(ER) Model

Handwritten Notes- Click Here


The Entity-Relationship (ER) Model is a conceptual data model. It helps database designers understand the requirements of a system before creating the actual database tables.

It describes the important objects in a system, their properties, and the relationships between them.

The three basic concepts of the ER model are

  • Entity
  • Attribute
  • Relationship


Entity

  • An entity can be any real-world object, person, place, or class about which we want to store information in a database.
  • In a traditional ER diagram, an entity is represented by a rectangle.                      

Example: Employee and Department

An employee works for a department. Here, Employee and Department are entities, and Works For is the relationship between them.

Weak Entity

  • A weak entity is an entity that depends on another entity for its identification of existence.
  • A weak entity is represented by a double rectangle .
Example: Loan and Installment
The Installment entity depends on the Loan entity.






Attribute
An attribute is a property or characteristic used to describe an entity.
an attribute is represented by an ellipse.

For example, the attributes of a Student entity may include ID, Name, Age, and Phone Number.

Types of Attributes

  1. Key Attribute
  2. Composite Attribute
  3. Multivalued Attribute
  4. Derived Attribute
1.Key Attribute
  • A key attribute is used to uniquely identify an entity.
  • A key attribute is represented by an ellipse with its name underlined.
  • Example: Student_ID can uniquely identify each student
2.Composite Attribute
  • A composite attribute is an attribute that can be divided into smaller meaningful attributes.
  • In an ER diagram, a composite attribute is represented by an ellipse connected to its component ellipses.
  • For example, Name can be divided into First Name, Middle Name, and Last Name.

3.Multivalued Attribute
  • A multivalued attribute can have more than one value for a single entity.
  • A multivalued attribute is represented by a double ellipse.
  • For example, a student may have multiple phone numbers. Therefore, Phone Number can be a multivalued attribute.
4. Derived Attribute
  • A derived attribute is an attribute whose value can be calculated from another attribute.
  • A derived attribute is represented by a dashed ellipse.
  • For example, a person's age can be calculated using their date of birth. Age is therefore a derived attribute.





Relationship

  • A relationship is used to describe the association between two or more entities.
  •  A relationship is represented by a diamond or rhombus.

Example: Teacher and Student

A teacher teaches students. Teacher and Student are the entities, and Teaches is the relationship.

Types of Relationships

The four main types of relationships are:

  1. One-to-One Relationship
  2. One-to-Many Relationship
  3. Many-to-One Relationship
  4. Many-to-Many Relationship

1. One-to-One Relationship (1:1)

  • A one-to-one relationship occurs when one instance of an entity is associated with one instance of another entity.
  • For example, one person may have one passport, and one passport belongs to one person.


2. One-to-Many Relationship (1:N)

  • A one-to-many relationship occurs when one instance of an entity on the left is associated with many instances of another entity on the right.
  • For example, one scientist can invent many inventions.

3. Many-to-One Relationship (N:1)

  • A many-to-one relationship occurs when many instances of an entity on the left are associated with one instance of an entity on the right.
  • For example, many students may enroll in one course.

4. Many-to-Many Relationship (N:N)
  • A many-to-many relationship occurs when many instances of one entity are associated with many instances of another entity.
  • For example, an employee can be assigned to many projects, and a project can have many employees.


Video Explanation



Comments

Popular posts from this blog

Queue ADT

Different types of Data Models in DBMS