Tutorials Logic, IN +91 8092939553 info@tutorialslogic.com
FAQs Support
Navigation
Home About Us Contact Us Blogs FAQs
Tutorials
All Tutorials
Services
Academic Projects Resume Writing Interview Questions Website Development
Compiler Tutorials

ER Model in DBMS

What is the ER Model?

The Entity-Relationship (ER) model is a high-level conceptual data model used to describe the structure of a database. It was proposed by Peter Chen in 1976. The ER model represents real-world objects as entities, their properties as attributes, and the connections between them as relationships.

ER diagrams are used during the database design phase to visualize the data structure before creating the actual database schema.

Entities and Attributes

An entity is a real-world object or concept that can be distinctly identified. Examples: Student, Employee, Product, Order.

An attribute is a property or characteristic of an entity. Types of attributes:

Attribute TypeDescriptionExample
Simple (Atomic)Cannot be divided furtherAge, Gender
CompositeCan be divided into sub-partsName → (First, Last)
MultivaluedCan have multiple valuesPhone numbers, Email addresses
DerivedComputed from other attributesAge (from Date of Birth)
Key AttributeUniquely identifies an entityStudent_ID, Employee_ID
Null AttributeMay have no valueMiddle name

Relationships and Cardinality

A relationship describes how entities are associated with each other. The cardinality defines the number of entity instances that can participate in a relationship:

CardinalityNotationExample
One-to-One (1:1)1 — 1Person has one Passport
One-to-Many (1:N)1 — NDepartment has many Employees
Many-to-One (N:1)N — 1Many Employees belong to one Department
Many-to-Many (M:N)M — NStudents enroll in many Courses; Courses have many Students

Participation Constraints

Participation constraints define whether all or some entity instances must participate in a relationship:

  • Total Participation (Mandatory): Every entity instance MUST participate in the relationship. Represented by a double line in ER diagrams. Example: Every Employee MUST work for a Department.
  • Partial Participation (Optional): Some entity instances may not participate. Represented by a single line. Example: Some Employees may not manage a Department.

Weak Entities

A weak entity is an entity that cannot be uniquely identified by its own attributes alone — it depends on a strong (owner) entity for its identification. Weak entities:

  • Do not have a primary key of their own
  • Have a partial key (discriminator) that identifies them within the context of the owner entity
  • Have a total participation in the identifying relationship
  • Represented by a double rectangle in ER diagrams

Example: An Order_Item entity is weak — it depends on the Order entity. An item number (1, 2, 3...) only makes sense within a specific order.

ER Diagram Notation Summary

SymbolRepresents
RectangleEntity
Double RectangleWeak Entity
EllipseAttribute
Double EllipseMultivalued Attribute
Dashed EllipseDerived Attribute
Underlined AttributeKey Attribute (Primary Key)
DiamondRelationship
Double DiamondIdentifying Relationship (for weak entity)
Single LinePartial Participation
Double LineTotal Participation
1, N, MCardinality ratios

Example: University ER Model

Consider a university database with the following entities and relationships:

  • STUDENT (Student_ID, Name, DOB, Email) — Key: Student_ID
  • COURSE (Course_ID, Title, Credits) — Key: Course_ID
  • INSTRUCTOR (Instructor_ID, Name, Department) — Key: Instructor_ID
  • DEPARTMENT (Dept_ID, Dept_Name, Location) — Key: Dept_ID

Relationships:

  • ENROLLS: Student M:N Course (with attribute: Grade, Semester)
  • TEACHES: Instructor 1:N Course
  • BELONGS_TO: Instructor N:1 Department
  • OFFERS: Department 1:N Course

Ready to Level Up Your Skills?

Explore 500+ free tutorials across 20+ languages and frameworks.