0
0
DbmsConceptBeginner · 3 min read

Cardinality in ER Diagram: Definition and Examples

In an ER diagram, cardinality defines the number of instances of one entity that can or must be associated with instances of another entity. It shows the minimum and maximum relationships, such as one-to-one, one-to-many, or many-to-many.
⚙️

How It Works

Cardinality in an ER diagram tells us how many objects in one entity relate to objects in another entity. Imagine a classroom: one teacher can teach many students, but each student has only one teacher for a subject. This relationship is described by cardinality.

It uses numbers or symbols near the connecting lines between entities to show the minimum and maximum number of relationships. For example, a "one-to-many" cardinality means one entity instance links to many instances of another entity, while "one-to-one" means each instance links to exactly one instance.

💻

Example

This example shows cardinality between two entities: Author and Book. An author can write many books, but each book has exactly one author.

plaintext
Entity: Author
Entity: Book
Relationship: Writes
Cardinality: Author (1) --- (1..*) Book
Output
Author 1 --- 1..* Book (One author writes one or many books)
🎯

When to Use

Use cardinality when designing databases to clearly define how entities relate to each other. It helps avoid confusion about data rules, like how many orders a customer can place or how many employees work in a department.

In real life, cardinality is useful for modeling systems such as school databases, online stores, or employee management, ensuring the database structure matches actual relationships.

Key Points

  • Cardinality shows the number of possible relationships between entities.
  • Common types are one-to-one, one-to-many, and many-to-many.
  • It helps define database rules and constraints clearly.
  • Cardinality is represented near relationship lines in ER diagrams.

Key Takeaways

Cardinality defines how many instances of one entity relate to another in an ER diagram.
It clarifies database relationship rules like one-to-one or one-to-many.
Using cardinality helps design accurate and efficient database structures.
Cardinality is shown with numbers or symbols on relationship lines in ER diagrams.