0
0
DBMS Theoryknowledge~6 mins

ER diagram notation in DBMS Theory - Full Explanation

Choose your learning style9 modes available
Introduction
When designing a database, it can be hard to organize how data relates to each other. ER diagrams help by showing these relationships visually, making it easier to plan and understand the database structure.
Explanation
Entity
An entity represents a real-world object or concept that has data stored about it. It is shown as a rectangle in the diagram. Entities can be things like a person, place, or event.
Entities are the main objects or concepts represented in the database.
Attribute
Attributes are the details or properties that describe an entity. They are shown as ovals connected to their entity. For example, a 'Person' entity might have attributes like 'Name' and 'Age'.
Attributes provide specific information about an entity.
Relationship
A relationship shows how two or more entities are connected or interact. It is represented by a diamond shape between entities. For example, a 'Student' entity might have an 'Enrolls' relationship with a 'Course' entity.
Relationships link entities to show how they relate to each other.
Cardinality
Cardinality defines the number of instances of one entity that can be associated with instances of another entity. It is usually shown near the relationship lines with symbols like 1, N, or M. For example, one teacher can teach many students.
Cardinality specifies how many entities participate in a relationship.
Primary Key
A primary key is an attribute or set of attributes that uniquely identifies each entity instance. It is often underlined in the diagram. For example, a 'Student ID' uniquely identifies each student.
Primary keys uniquely identify each record in an entity.
Real World Analogy

Imagine a school directory where each student is listed with their details and the classes they attend. The students are entities, their details like name and age are attributes, the classes they attend are relationships, and the number of classes per student shows cardinality.

Entity → A student listed in the directory
Attribute → Details like the student's name and age
Relationship → The connection showing which classes the student attends
Cardinality → How many classes a student can attend
Primary Key → The unique student ID number
Diagram
Diagram
┌───────────┐       ┌─────────────┐
│  Entity   │────◆───│ Relationship│
└───────────┘       └─────────────┘
     │                   │
     ○                   ○
  Attribute           Cardinality

(Primary key is underlined in Attribute oval)
This diagram shows entities as rectangles, relationships as diamonds, attributes as ovals, and cardinality near the relationship lines.
Key Facts
EntityA real-world object or concept represented as a rectangle.
AttributeA property or detail of an entity shown as an oval.
RelationshipA connection between entities shown as a diamond.
CardinalityThe number of entity instances involved in a relationship.
Primary KeyAn attribute that uniquely identifies an entity instance, underlined in diagrams.
Common Confusions
Thinking relationships are entities.
Thinking relationships are entities. Relationships represent connections between entities, not objects themselves.
Believing attributes can connect entities directly.
Believing attributes can connect entities directly. Attributes describe entities; only relationships connect entities.
Assuming cardinality symbols are optional or decorative.
Assuming cardinality symbols are optional or decorative. Cardinality is essential to understand how many instances participate in relationships.
Summary
ER diagrams use rectangles for entities, ovals for attributes, diamonds for relationships, and symbols to show cardinality.
Entities represent things, attributes describe them, and relationships connect them.
Primary keys uniquely identify each entity instance and are underlined in the diagram.