शुभ दीपावली! NotesMedia की ओर से आपको और आपके परिवार को ढेरों शुभकामनाएं ✨ शुभ दीपावली! आपको और आपके परिवार को शुभकामनाएं ✨ शुभ दीपावली! ✨
BCA / B.Tech 9 min read

E R (Entity Relationship) Model in Hindi

RK

लेखक Ratan Kumawat · संस्थापक, NotesMedia

प्रकाशित:

त्वरित सारांश और मुख्य बिंदु

  • • विषय फोकस: DBMS Notes in Hindi | डीबीएमएस नोट्स (BCA / B.Tech Syllabus)
  • • मुख्य विषय: E R (Entity Relationship) Model in Hindi - General Topics
  • • अवलोकन: Quick Answer: ER Model (Entity-Relationship Model) database design का एक diagram वाला तरीका है, जिसे Peter Chen ने 1976 में दिया था। इसमें हम real world...
  • • मुख्य अवधारणाएं: ER model, Entity relationship diagram Hindi, Cardinality attributes,
Quick Answer: ER Model (Entity-Relationship Model) database design का एक diagram वाला तरीका है, जिसे Peter Chen ने 1976 में दिया था। इसमें हम real world की चीज़ों को entity (rectangle), उनकी properties को attribute (oval) और उनके आपसी connection को relationship (diamond) से दिखाते हैं। Tables बनाने से पहले ER diagram बनाया जाता है, ताकि design की गलती कागज़ पर ही पकड़ में आ जाए।

ER Model क्या है और Tables से पहले क्यों बनता है?

ER Model एक conceptual (high-level) data model है। इसमें अभी कोई table, column type या SQL नहीं होता। हम सिर्फ़ यह तय करते हैं कि system में कौन-कौन सी चीज़ें हैं, उनके बारे में क्या store करना है, और वो आपस में कैसे जुड़ी हैं। Data models के बाकी types के लिए देखें: Data Models in Hindi.

Tables से पहले ER diagram बनाने के तीन सीधे फ़ायदे हैं:

  • Client से बात आसान: college का principal SQL नहीं समझता, पर boxes और lines वाला diagram देखकर बता सकता है कि "एक course को एक ही teacher पढ़ाता है" सही है या नहीं।
  • गलती सस्ते में पकड़ में आती है: diagram में एक line बदलना आसान है, पर data भरने के बाद table तोड़ना महंगा पड़ता है।
  • Tables अपने आप निकल आते हैं: सही ER diagram हो तो कुछ fixed rules से उसे सीधे tables में बदला जा सकता है (नीचे mapping section देखें)।

E R  (Entity Relationship) Model in Hindi

Advertisement

ER Model के Components

ER Model के तीन main parts हैं: Entity, Attribute और Relationship।

1. Entity

Entity real world की कोई भी चीज़ है जिसका data हमें रखना है और जिसे बाकी चीज़ों से अलग पहचाना जा सके। यह physical भी हो सकती है (Student, Book) और concept भी (Course, Loan)। एक ही type की सारी entities मिलकर entity set बनाती हैं, जैसे सारे students। Entity set पर अलग note: Entity Set in Hindi.

Diagram में entity को rectangle से दिखाते हैं।

Strong Entity vs Weak Entity

PointStrong EntityWeak Entity
पहचानअपनी primary key से खुद पहचानी जाती हैअपनी पूरी key नहीं होती, owner (strong) entity की key के साथ ही पहचानी जाती है
KeyPrimary key (solid underline)Partial key / discriminator (dashed underline)
SymbolSingle rectangleDouble rectangle
Owner से relationshipNormal diamondDouble diamond (identifying relationship)
ParticipationPartial या totalIdentifying relationship में हमेशा total
ExampleEmployee (EmpID)Dependent (DepName)

Example: किसी company में employee के family members (Dependent) का data रखना है। "Riya" नाम की dependent दो अलग employees की बेटी हो सकती है, इसलिए सिर्फ़ DepName से row unique नहीं होगी। Key बनेगी (EmpID + DepName)। Employee delete हुआ तो उसके dependents का भी कोई मतलब नहीं बचता। यही weak entity की पहचान है।

2. Attribute

Attribute किसी entity की property है, जैसे Student का RollNo, Name, Age। Diagram में attribute को oval से दिखाते हैं और line से उसकी entity से जोड़ते हैं। Attributes के सभी types पर अलग note भी है: Types of Attributes in Hindi.

TypeमतलबExampleSymbol
Simpleजिसे और छोटे parts में नहीं तोड़ सकतेRollNo, AgeOval
Compositeजो छोटे parts से मिलकर बना हैName = FirstName + LastNameOval, जिससे छोटे ovals जुड़े हों
Single-valuedएक entity के लिए एक ही valueDateOfBirthOval
Multi-valuedएक entity के लिए कई valuesPhoneNo (एक student के दो नंबर)Double oval
DerivedStore नहीं होता, दूसरे attribute से calculate होता हैAge (DateOfBirth से)Dashed oval
Keyजिससे हर entity unique पहचानी जाएRollNoOval में नाम underlined

ध्यान दें: simple/composite और single/multi-valued दो अलग classifications हैं। एक attribute एक साथ composite और multi-valued भी हो सकता है, जैसे किसी के कई Address, और हर Address में City, PIN। Key कितने type की होती है (super, candidate, primary, foreign), यह यहाँ पढ़ें: Keys in DBMS in Hindi.

3. Relationship

Relationship दो या ज़्यादा entities के बीच का connection है, जैसे Student Enrolls Course, Teacher Teaches Course। Diagram में इसे diamond से दिखाते हैं। Relationship का भी अपना attribute हो सकता है, जैसे Enrolls का Grade (यह न अकेले Student का है, न अकेले Course का)।

Relationship की degree (unary, binary, ternary), descriptive attribute और SQL examples के लिए पूरा note पढ़ें: Relationship Set in Hindi.

ER Diagram Symbols Table

Shapeमतलब
RectangleStrong entity
Double rectangleWeak entity
DiamondRelationship
Double diamondIdentifying relationship (weak entity को owner से जोड़ता है)
OvalAttribute
Oval, नाम underlinedKey attribute
Oval, नाम dashed underlinePartial key (weak entity का discriminator)
Double ovalMulti-valued attribute
Dashed ovalDerived attribute
Oval से जुड़े छोटे ovalsComposite attribute
Single linePartial participation
Double lineTotal participation
Line पर 1, N, MCardinality

Cardinality (Mapping Cardinality)

Cardinality बताती है कि एक तरफ़ की एक entity, relationship के ज़रिए दूसरी तरफ़ की कितनी entities से जुड़ सकती है। Diagram में line के ऊपर 1, N या M लिखते हैं।

CardinalityमतलबExample
One-to-One (1:1)एक A सिर्फ़ एक B से, और एक B सिर्फ़ एक A सेPerson — Passport
One-to-Many (1:N)एक A कई B से, पर हर B सिर्फ़ एक A सेTeacher — Course (एक teacher कई courses पढ़ाता है)
Many-to-One (N:1)1:N को उल्टी तरफ़ से देखनाCourse — Teacher (कई courses एक teacher के पास)
Many-to-Many (M:N)दोनों तरफ़ कईStudent — Course

Participation Constraint

  • Total participation (double line): entity set की हर entity का relationship में होना ज़रूरी है। जैसे college का हर Course किसी न किसी Teacher को assign होना ही चाहिए।
  • Partial participation (single line): कुछ entities relationship में न भी हों तो चलेगा। जैसे कोई नया Teacher अभी कोई course न पढ़ा रहा हो।

Cardinality "कितने" बताती है, participation "ज़रूरी है या नहीं" बताता है। Exam में दोनों को mix मत करना।

Worked Example: College Database

Requirement: College में Students, Courses और Teachers हैं। एक student कई courses ले सकता है और एक course में कई students होते हैं। हर course को ठीक एक teacher पढ़ाता है, और एक teacher कई courses पढ़ा सकता है। Student के एक से ज़्यादा phone numbers हो सकते हैं। हर enrollment पर student का grade store करना है।

Step 1: Entities, Attributes और Relationships पहचानें

EntityAttributes (key underlined होगी)
StudentRollNo (key), Name, DOB, PhoneNo (multi-valued), Age (derived)
CourseCourseID (key), Title, Credits
TeacherTeacherID (key), Name, Dept
  • Enrolls: Student — Course, M:N, attribute Grade
  • Teaches: Teacher — Course, 1:N, Course की तरफ़ total participation

Step 2: ER Sketch

   (Name) ((PhoneNo)) [Age]         (Grade)        (Title) (Credits)
       \      |      /                 |               \     /
(RollNo)─[ Student ]──M──< Enrolls >──N──[ Course ]═N═< Teaches >─1─[ Teacher ]─(TeacherID)
              |                             |                          |     \
            (DOB)                       (CourseID)                  (Name) (Dept)

 [ ]  = entity (rectangle)        < > = relationship (diamond)
 ( )  = attribute (oval)          (( )) = multi-valued (double oval)
 [Age] = derived (dashed oval)    ═ = total participation (double line)
 RollNo, CourseID, TeacherID = key attributes (असली diagram में underlined)

Course और Teaches के बीच double line इसलिए है क्योंकि कोई भी course बिना teacher के नहीं रह सकता। Teacher की तरफ़ single line है, क्योंकि कोई teacher बिना course के भी हो सकता है।

Step 3: ER से Tables (ER → Relational Mapping Rules)

ER में क्या हैTable में कैसे बदलेगा
Strong entityअपनी table; simple attributes columns बनते हैं, key attribute primary key बनता है
Composite attributeसिर्फ़ उसके छोटे parts columns बनते हैं (FirstName, LastName)
Derived attributeColumn नहीं बनता, query में calculate होता है
Multi-valued attributeअलग table: entity की key + वह attribute, दोनों मिलकर primary key
1:N relationship"1" वाली side की primary key, "N" वाली table में foreign key बनकर जाती है
1:1 relationshipकिसी एक table में दूसरी की key foreign key बनकर जाती है (बेहतर: total participation वाली side में)
M:N relationshipअलग table: दोनों entities की keys (मिलकर primary key) + relationship के attributes
Weak entityअपनी table, जिसमें owner की primary key foreign key बनकर आती है; primary key = owner key + partial key

इन rules से College database की tables:

Student      (RollNo PK, Name, DOB)                -- Age नहीं, वो DOB से निकलेगी
Student_Phone(RollNo FK, PhoneNo)    PK = (RollNo, PhoneNo)      -- multi-valued
Teacher      (TeacherID PK, Name, Dept)
Course       (CourseID PK, Title, Credits, TeacherID FK NOT NULL)  -- 1:N
Enrolls      (RollNo FK, CourseID FK, Grade)  PK = (RollNo, CourseID)  -- M:N

Course.TeacherID पर NOT NULL इसलिए है क्योंकि Course की participation total है। Teaches के लिए अलग table नहीं बनी, क्योंकि 1:N में foreign key काफ़ी है।

Weak entity का example (Employee — Dependent) table में ऐसा बनेगा:

Dependent(EmpID FK, DepName, Relation)   PK = (EmpID, DepName)
Advertisement

किसी भी Question में ER Diagram कैसे बनाएँ (Steps)

  1. Nouns छाँटें: question में जो चीज़ें बार-बार आती हैं और जिनका data रखना है (Student, Course, Teacher), वो entities बनेंगी।
  2. हर entity की properties लिखें: Name, DOB जैसी चीज़ें attributes हैं। हर entity के लिए एक key attribute ज़रूर चुनें और उसे underline करें।
  3. Verbs छाँटें: "enrolls", "teaches", "issues" जैसे verbs relationships बनेंगे।
  4. Cardinality लगाएँ: हर relationship के लिए दोनों तरफ़ से पूछें: "एक student कितने courses?" और "एक course में कितने students?"
  5. Participation तय करें: पूछें कि क्या हर entity का इस relationship में होना ज़रूरी है। हाँ तो double line।
  6. Weak entity check करें: कोई entity ऐसी है जो अपनी key से unique नहीं होती और owner के बिना उसका मतलब नहीं? तो double rectangle और double diamond लगाएँ।

Students की Common गलतियाँ

  • Relationship के attribute को entity में डाल देना: Grade को Student entity में लिखना गलत है, क्योंकि एक student के हर course में अलग grade है। यह Enrolls का attribute है।
  • Multi-valued attribute को single oval में बनाना: PhoneNo, Email, Skills जैसे attributes के कई values हो सकते हैं, इन्हें double oval में बनाएँ।
  • Derived attribute को table में column बना देना: Age, TotalMarks जैसे attributes mapping में column नहीं बनते।
  • Weak entity को बिना owner के बनाना: double rectangle बनाया है तो उसके साथ double diamond और owner entity भी ज़रूर दिखाएँ, वरना diagram अधूरा माना जाता है।
  • M:N के लिए foreign key से काम चलाना: M:N relationship को किसी एक table में foreign key डालकर नहीं दिखा सकते, इसके लिए अलग table ही बनेगी।

ER Model के Advantages और Limitations

AdvantagesLimitations
Diagram देखकर non-technical लोग भी design समझ लेते हैंData manipulation (insert, update, query) का कोई तरीका नहीं, यह सिर्फ़ structure दिखाता है
Fixed rules से सीधे relational tables में बदल जाता हैNotation एक जैसा नहीं: Chen, Crow's Foot, UML, हर किताब में symbols थोड़े अलग मिलते हैं
Design की गलती (missing relationship, गलत cardinality) coding से पहले पकड़ में आती हैबड़े system में diagram बहुत भीड़ वाला हो जाता है और पढ़ना मुश्किल होता है
किसी particular DBMS (MySQL, Oracle) से बंधा नहीं हैकुछ business rules (जैसे "grade A से F के बीच हो") diagram में नहीं दिखा सकते

Extended ER (EER) Features: एक line में

  • Generalization: कई entities की common बातें निकालकर एक ऊपर वाली entity बनाना (bottom-up), जैसे Car और Bike से Vehicle। पढ़ें: Generalization & Inheritance in Hindi.
  • Specialization: इसका उल्टा (top-down): एक entity को sub-types में बाँटना, जैसे Employee से Teacher और Clerk।
  • Aggregation: पूरे relationship को एक entity की तरह treat करके उसे किसी दूसरे relationship से जोड़ना। पढ़ें: Aggregation in Hindi.

Exam के लिए Important Questions

Short Questions (2–3 marks)

  1. ER Model क्या है? इसे किसने और कब दिया?
  2. Strong और weak entity में अंतर बताइए। Weak entity को diagram में कैसे दिखाते हैं?
  3. Multi-valued और derived attribute को example और symbol के साथ समझाइए।
  4. Total और partial participation में क्या अंतर है?
  5. Partial key (discriminator) क्या होती है?

Long Questions (5–10 marks)

  1. ER Model के components को सभी symbols के साथ समझाइए।
  2. College (या Library / Hospital) database का ER diagram बनाइए और उसे tables में बदलिए।
  3. ER diagram को relational tables में बदलने के rules example के साथ लिखिए।
  4. Mapping cardinality और participation constraint को diagram के साथ समझाइए।

FAQs

ER Model किसने दिया था?

Peter Chen ने 1976 में अपने paper "The Entity-Relationship Model: Toward a Unified View of Data" में ER Model दिया था। आज जो rectangle-diamond-oval वाली notation पढ़ाई जाती है, उसे Chen notation कहते हैं।

ER Model और Relational Model में क्या अंतर है?

ER Model conceptual level पर diagram से design दिखाता है, जबकि Relational Model उसी design को tables, rows और keys के रूप में implement करता है। पहले ER बनता है, फिर mapping rules से relational tables।

M:N relationship के लिए अलग table क्यों बनानी पड़ती है?

क्योंकि किसी एक table के column में कई values नहीं रख सकते। Student table में CourseID रखें तो एक student के कई courses नहीं आएँगे, इसलिए Enrolls जैसी अलग table में हर pair की एक row बनती है।

Derived attribute को table में क्यों नहीं रखते?

क्योंकि उसकी value बदलती रहती है और दूसरे column से निकल आती है। Age store करें तो हर साल update करनी पड़ेगी, DOB store करें तो Age कभी गलत नहीं होगी।

ER diagram और EER diagram में क्या अंतर है?

EER (Enhanced ER) में basic ER के ऊपर generalization, specialization और aggregation जैसे features जुड़ जाते हैं, ताकि बड़े और complex systems का design भी दिखाया जा सके।

अक्सर पूछे जाने वाले प्रश्न (FAQs)

Quick Answer: ER Model (Entity-Relationship Model) database design का एक diagram वाला तरीका है, जिसे Peter Chen ने 1976 में दिया था।
DBMS Notes in Hindi | डीबीएमएस नोट्स के पाठ्यक्रम में E R (Entity Relationship) Model in Hindi एक महत्वपूर्ण अध्याय है। यह मुख्य सिद्धांतों, परीक्षा प्रश्नों और सूत्रों को समझने के लिए अत्यधिक आवश्यक है।
हाँ, NotesMedia पर आपको E R (Entity Relationship) Model in Hindi के महत्वपूर्ण प्रश्नोत्तर, हल किए गए उदाहरण और नोट्स बिल्कुल मुफ्त मिलेंगे। अधिक अभ्यास के लिए आप हमारा ऐप भी डाउनलोड कर सकते हैं।
Advertisement