Labs ICT
โญ Pro Login

Entity Relationship Diagrams

Model data structures and relationships using ER diagrams.

Entity Relationship Diagrams

Entity Relationship Diagrams (ERDs) model the data structures in a system and the relationships between them. They are essential tools for database design and help analysts understand what data the system needs to store and how entities relate to each other.

ERD Symbols

Entity              Attribute           Relationship

+----------+       ( name )            ---------->
|          |       ( id )              |          |
| Entity   |       ( type )            |  Lines   |
| Name     |                           |  with    |
+----------+                           |  symbols |
                                       ---------->

Rectangle =      Oval =            Diamond =        Line = connection
entity           attribute         relationship     between symbols

Key Concepts

Concept Description
Entity A person, place, thing, or event about which data is stored (e.g., Customer, Order)
Attribute A property or characteristic of an entity (e.g., name, email)
Primary Key An attribute that uniquely identifies each entity instance
Relationship An association between two or more entities
Cardinality The numerical relationship between entity instances (1:1, 1:N, M:N)

Cardinality Notation

One-to-One (1:1)
  Person ---- has ---- Passport

One-to-Many (1:N)
  Customer ---- places ---- Order
  (1 customer can place many orders)

Many-to-Many (M:N)
  Student ---- enrolls ---- Course
  (many students can enroll in many courses)
  Resolved using a junction/bridge entity

Example: Library System ERD

  +----------+         +-----------+         +----------+
  |  MEMBER  | 1     N | BORROWS   | N     1 |   BOOK   |
  +----------+---------+-----------+---------+----------+
  | member_id|         | borrow_id |         | book_id  |
  | name     |         | date_out  |         | title    |
  | email    |         | due_date  |         | author   |
  | phone    |         | returned  |         | isbn     |
  +----------+         +-----------+         +----------+

  +----------+         +-----------+
  |  AUTHOR  | 1     N |   BOOK    |
  +----------+---------+-----------+
  | author_id|         | book_id   |
  | name     |         | title     |
  | bio      |         | isbn      |
  +----------+         +-----------+

Steps to Create an ERD

  1. Identify all entities from requirements
  2. List the attributes for each entity
  3. Identify the primary key for each entity
  4. Determine relationships between entities
  5. Define cardinality (1:1, 1:N, M:N)
  6. Resolve many-to-many relationships with bridge entities
  7. Validate the ERD with stakeholders

Summary

ERDs provide a clear visual model of data structures and relationships. They are indispensable for database design and help ensure the system stores the right data with proper relationships and constraints.

๐Ÿงช Quick Quiz

In an Entity Relationship Diagram (ERD), a diamond shape represents: