Understanding ER Diagrams (Entity Relationship Diagrams)

📌 What is an ER Diagram?

ER Diagram (Entity Relationship Diagram) is a visual way to understand how data is stored in a database. It shows:

📌 How to Read an ER Diagram

Reading an ER diagram is simple:
  1. Identify all entities (tables)
  2. See which fields are primary keys (PK)
  3. Check which fields are foreign keys (FK)
  4. Follow the relationship lines connecting the tables
  5. Read 1 → * as "One-to-Many"

📌 Example of a Simple ER Diagram Sentence

If an ER diagram shows:
Users 1 ─────────── * Courses
    
It means:

One user can create many courses.

📌 ER Diagram Terms Explained

📌 Sample Code Showing a DB Structure

Table Users {
  _id PK
  name string
  email string
}

Table Courses {
  _id PK
  title string
  createdBy FK → Users._id
}

Relationship:
Users 1 → * Courses

📌 Best External References for Learning ER Diagrams