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
- Identify all entities from requirements
- List the attributes for each entity
- Identify the primary key for each entity
- Determine relationships between entities
- Define cardinality (1:1, 1:N, M:N)
- Resolve many-to-many relationships with bridge entities
- 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.