Delhi, India
← Back to DBMS

ER Model (Entity - Relationship Model)

Core CS Notes · DBMS · Topic 2 of 5


A non technical design method works on conceptual level based perception of the real world

Entity is an instance / values stored in a table at a particular time.

In ER Model, technically we are not talking about such instances / entity. ER is used for reading the database schema.

Entity

Entity is a thing or an object in the real world that is distinguishable from other object based on the values of the attributes it possesses

Types of Entity

  • Tangible : Physically in the real world like Car, Pen
  • Intangible : Exist logically, Account, Videos

Entity-Set

Collection of same type of entities that share the same properties / attributes.

In the ER diagram → represented by RECTANGLE

In relational model Entity Set → Separate table and Entity → Row / Tuple in a table.

Attributes

are the units that defines / describes the properties/ characteristics of the entities

For each attribute there is a set of permitted values called → DOMAIN.

In the ER diagram → Attributes → Oval / Double Circle / Dotted Circle

Types of Attributes

  • Single Valued → Single value hee ho sakti hai like Aadhaar Number, DOB etc etc
  • Double Valued → Email Address, Phone numbers … ek se zyada ho sakte hai, no fixed value. Represented by double circle.
  • Simple → Attributes which can be divided into sub parts
  • Composite → Further divided into sub parts; Name is connected to First_Name and Last_Name. When an oval is connected to two ovals, then the first oval is a composite attribute which is broken down into simple attributes.
  • Stored → Whose value is permanently stored in database, like DOB
  • Derived → If I know DOB then I can calculate the age attribute. So here Age is a Derived attribute. Represented by DOTTED OVAL. Calculated at runtime.
  • DESCRIPTIVE ATTRIBUTE
Incomplete in the original notes: no explanation written yet for Descriptive Attribute.

Relationships

Association between two or more entities of same or different entity set.

Teacher and Subject entity sets connected by a relationship diamond

Teacher and Subject are two Entity set, T1 Teacher teaches Subjects S1 and S2 etc etc.

DIAMOND SHAPE → Relationship Set

Every relation should need

  • Name
  • Degree
  • Structural Constraints

Degree

number of entities set involved in a relationship.

Unary Relationship

Self referential / one single entity participate in a relationship.

A member in a team maybe supervisor of another member in a team, relationship between same set to same set. Class CR Students bhi same example

Structural Constraints

One to One, One to Many, Many to One, Many to Many

Min Cardinality → minimum numbre of times an entity participates in a relationship.

Max Cardinality

Participation Constraints

  • Partial Participation → Only some entities participate in a relationship, there is one entity which do not have links to other
  • Total Participation → Every entity of an entity set participates in at least one relationship

Strong And Weak Entity Set

If an entity set has a primary key, and all the tuples in the set are distinguishable by that key, then STRONG SET

If sufficient attributes are missing → WEAK ENTITY SET, represented by a double rectangle box. It contains the DISCRIMINATOR ATTRIBUTES, represented by Dotted Underline … (PARTIAL KEY) which contains the partial information.

This relationship is represented by DOUBLE DIAMOND

MINIMUM NUMBER OF TABLES REQUIRED

  • Many to Many mai separate table to banana hee padega, for many to one or one to many, jo One wala hai, uski primary key, add it into many wala table.
  • Multi valued attributes ke liye alag se table banegi, represented by two circles.