Sources

  1. Mermaid, “Entity Relationship Diagrams” - Accessed 2024-11-02
  2. Lucidchart, “What is an Entity Relationship Diagram (ERD)?” - Accessed 2024-11-02, archived on 2021-10-18

Introduction

ER Diagrams are used to illustrate the relationship of tables or entities in databases.

Components

Entity

  • Entities store information and can be thought of like proper nouns. It is represented as a rectangle.
  • Entity type is the group of the entity (like common nouns). For example, the student is the entity type, while the specific student is the entity.
  • Entity set is like entity type but with time.
  • Entity categories:
    1. Strong entity: An entity defined solely by its attributes
    2. Weak entity: An entity that is not only defined by its own attributes.
    3. Associative entity: Ties entities with entity sets.
  • Entity keys:
    1. Super key: is the set of attributes that define an entity in an entity set.
    2. Candidate key: a super key with the minimum amount of attributes needed to be a super key.
    3. Primary key: a candidate key used to uniquely identify an entity set.
    4. Foreign key: indicates the relationship between entities.

Relationship

  • Relationships are like verbs to nouns in which verbs illustrate how nouns interact with each other. It is represented as a diamond.
  • A recursive relationship is one where the same entity interacts with another entity multiple times.

Attribute

  • Attributes indicate the properties of an entity (like adjectives), while descriptive attributes indicate the properties of a relationship (like adverbs). They are usually represented using an oval or circle.
  • Attribute categories
    1. Simple: Denotes that the attribute cannot be divided into simpler parts.
    2. Composite: Denotes that the attribute is composed of simpler attributes known as sub-attributes.
    3. Derived: Indicates that the attribute is either derived from other attributes or is computed.
  • A multi-value attribute implies that the entity has more than one value for a particular attribute. Conversely, a single-value implies that it only holds a single value.

Cardinality

  • Cardinality refers to the numerical property of the relationship between two entities/entity sets.