Purpose: Helps design structured databases by visually mapping out relationships between data.
Concept | Explanation | Example |
---|---|---|
Entity | Object or concept that stores data | Customer , Product , Order |
Entity Set | Collection of similar entities | All customers in an app |
Attributes | Properties that describe each entity | email , price , orderDate |
Primary Key | Uniquely identifies an entity | customer_id , order_id |
Weak Entity | Depends on another entity, lacks a PK | OrderItem depends on Order |
Type | Example Application |
---|---|
1:1 | Each User has one Profile |
1:N (One-to-Many) | One Customer places many Orders |
M:N (Many-to-Many) | Students enroll in many Courses , and each course has many students |
Relationships can be:
Employee
manages another Employee
Doctor
+ Patient
+ Hospital
)Strategy | Real-World Use Case |
---|---|
Specialization | Payment can specialize into CreditCard , PayPal , UPI |
Generalization | Admin and Customer generalize into a single User type |
Used when a relationship has its own attributes.
Example: WorksOn
can become its own entity with hoursBilled
, used in a Billing
relationship.
Project ←– WorksOn –→ Employee