DEV Community

Cover image for ENTITY RELATION MODEL (ERM)
Jedidiah Ken Osuh
Jedidiah Ken Osuh

Posted on

ENTITY RELATION MODEL (ERM)

INTRODUCTION

What is Entity Relationship?

Entity-Relationship (ER) refers to a modeling technique used in software engineering and database design to visually represent the structure of data and the relationships between different entities within a system. In this context, an entity is a real-world object or concept that has attributes describing its properties, and relationships describe how entities interact or are associated with each other.

An Entity Relationship Diagram — sometimes called a model — is a powerful tool for data modeling that allows developers and designers to create a visual representation of data and its relationships. ERDs are based on the concept of entities, which are objects or concepts that have independent existence and can be represented as rectangles in an ERD. Attributes are properties of an entity that describe its characteristics or features and are represented as ovals in an ERD.

COMPONENTS OF ENTITY RELATIONSHIP

- ENTITY

What is an Entity?

An Entity is a thing in the real world with an independent existence. An entity is a real-world object or concept that has attributes describing its properties.
E.g. In a university database, entities could include students, courses, professors, and departments.

What are Weak Entities?

Weak Entities are those entities that depend on other entities for their existence. It can be identified uniquely by considering the primary key of another entity. For that, weak entity sets need to have participations. Weak entities don't contain any key attribute of its own.
E.g. Library Member Card (Weak Entity) Relies on the Library Member (Strong Entity) for its existence, as it cannot exist without a member; its primary key might consist of a combination of its own attributes and the member's ID.

- Attributes

What are Attributes?

Attributes are properties or characteristics that describe entities.
E.g. A student entity may have attributes like student ID, name, date of birth, etc.

  • What are Key Attributes?

A key attribute is used to represent the main characteristics of an entity. Key attributes, also known as key fields or key columns, are the attributes within an entity or a table that uniquely identify each instance or record. These attributes are crucial for maintaining data integrity and facilitating efficient data retrieval in a database. There are primarily two types of key attributes:

1. Primary Key:

 A primary key is a set of one or more attributes that uniquely identifies each record in a table.
Enter fullscreen mode Exit fullscreen mode

E.g. In a "Student" table, the primary key might be the
"StudentID" attribute.

2. Foreign Key:

A foreign Key is an attribute in one table that refers to the primary key of another table, establishing a link between the two tables. 
Enter fullscreen mode Exit fullscreen mode

E.g. In an "Enrollment" table, the "StudentID" attribute might be a foreign key referencing the primary key
"StudentID" in the "Student" table.

  • What are Composite Attributes?

Composite Attributes are attributes that are composed of many other attributes.
E.g. In an entity of students, the “name” attribute can be composite because it is composed or formed from other attributes like first name, last name and middle name. Etc.

  • What are Multivalued Attributes?

Multivalued Attributes are attributes with more than one value.
E.g. A student entity with an attribute of “phonenumber” is a multivalued attribute because a student can have more than one phone number which is more than one value.

  • What are Derived Attributes?

Derived Attributes are attributes that are obtained from other attributes.
E.g. A students “age” is an attribute that is gotten from the “date of birth” attribute.

- Relationships

What are Relationships?

Relationships describe how entities interact or are associated with each other.
E.g. A student takes courses, so there's a relationship between the student and course entities.

Types of Relationships

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

    In this relationship each instance of one entity is
    associated with exactly one instance of another entity, and
    vice versa.
    E.g. Consider a "Person" entity and a "Passport" entity. Each person has exactly one passport, and each passport
    belongs to exactly one person.

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

    In this relationship each instance of one entity can be associated with many instances of another entity, but each instance of the other entity is associated with only one instance of the first entity.
    E.g. In a "Customer" and "Order" relationship, one customer can place multiple orders, but each order is placed by only one customer.

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

    The reverse of one-to-many; many instances of one entity can be associated with only one instance of another entity.
    E.g. In a "Child" and "Parent" relationship, many children can have the same parent (e.g., a mother or a father).

  4. Many-to-Many (M:M):

    In this relationship many instances of one entity can be associated with many instances of another entity.
    E.g. Consider a "Student" and "Course" relationship. Many students can enroll in many courses, and each course can have many students.

ENTITY RELATIONSHIP(ER) MODEL FOR AN EDUCATION SYSTEM

  • Keys

[Image description]

  • Diagram

[Image description]

Top comments (0)