Free tutorials & notes in Hindi & English · Clean code examples 🧰 मुफ़्त PDF और फ़ोटो टूल्स →
MySQL + SQL · Lesson 24

Entity, Relationship और Attributes

तीन building blocks

ER model तीन चीज़ों से बना है: entities (वस्तुएँ), attributes (उनकी details) और relationships (कैसे जुड़ती हैं)। इनमें से हर एक अलग प्रकारों में आती है, और इन्हें जानना असल स्थितियाँ सटीक model करने में मदद करता है।

💡 Entities, attributes और relationships हर एक के कई प्रकार हैं जो आप कुछ भी model करने को मिला सकते हैं।

Strong और weak entities

  • Strong entity — इसकी अपनी key होती है और यह अकेली खड़ी रहती है (Student, Book)। Single rectangle के रूप में बनती।
  • Weak entity — इसकी अपनी key नहीं; यह पहचानी जाने को strong entity पर निर्भर (Employee से जुड़ा Dependent)। Double rectangle के रूप में बनती।

Weak entity को अपनी owning strong entity तक एक identifying relationship (double diamond) चाहिए।

Attributes के प्रकार

प्रकारमतलबउदाहरण
SimpleAtomic, बाँट नहीं सकतेage
Compositeहिस्सों से बनापूरा नाम (first + last)
Single-valuedसिर्फ़ एक valuedate of birth
Multivaluedकई valuesphone numbers
Derivedदूसरों से गणनाDOB से age
Keyविशिष्ट पहचानताroll number

Relationships के प्रकार

Cardinality से — कितने कितनों से जुड़ते हैं:

  • One-to-one (1:1) — एक person और उनका passport।
  • One-to-many (1:N) — एक department और उसके students।
  • Many-to-many (M:N) — students और courses।

Cardinality तय करती है foreign keys कहाँ जाएँ, और link table चाहिए या नहीं (M:N को)।

Relationship की degree

  • Unary — एक entity खुद से जुड़ी (एक Employee दूसरे Employee को "manage" करता)।
  • Binary — दो entities (Student "enrolls in" Course)। सबसे आम।
  • Ternary — एक relationship में तीन entities।

Degree गिनती है कितनी entities भाग लेती हैं; cardinality गिनती है कितने instances।

सब जोड़कर

एक library सोचिए:

  • Entities: Member (strong), Book (strong)।
  • Attributes: Member के पास id (key), name, और phone numbers (multivalued)।
  • Relationship: Member Book "borrow करता है" — many-to-many binary relationship।

यह Member और Book tables और borrowing को link table पर mapped होता है।

आम गलतियाँ

  • Weak entity को strong मानना। इसकी अपनी key नहीं; इसे owner से जोड़िए।
  • Derived attribute store करना। अक्सर store करने के बजाय गणना करना बेहतर।
  • Degree और cardinality मिलाना। Degree = entities की संख्या; cardinality = instances की संख्या।
  • Link table बिना many-to-many model करना। M:N को एक चाहिए।

सारांश

  • Entities strong (अपनी key) या weak (निर्भर) हो सकती हैं।
  • Attributes: simple, composite, single/multivalued, derived, key।
  • Relationships cardinality से: 1:1, 1:N, M:N।
  • Degree है कितनी entities relationship में जुड़ती हैं (unary, binary, ternary)।
  • ये प्रकार साथ में आपको कोई भी असल स्थिति model करने देते हैं।

आगे, समग्र ER model सीखिए, या drawing symbols ER diagram symbols में।

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

Strong और weak entity में क्या अंतर है?
Strong entity की अपनी key होती है और यह अपने-आप मौजूद रहती है, जैसे Student। Weak entity की अपनी key नहीं होती और पहचानी जाने को strong entity पर निर्भर होती है, जैसे Dependent जो सिर्फ़ Employee से जुड़कर मायने रखता है।
DBMS में attributes के प्रकार क्या हैं?
आम प्रकार हैं: simple (atomic, जैसे age), composite (हिस्सों से बना, जैसे पूरा नाम), single-valued (एक value), multivalued (कई, जैसे phone numbers), derived (गणना किया, जैसे DOB से age), और key (entity को विशिष्ट पहचानता)।
DBMS में relationships के प्रकार क्या हैं?
Cardinality से: one-to-one, one-to-many, और many-to-many। ये बताते हैं एक entity के कितने instances दूसरी के instances से जुड़ते हैं, और तय करते हैं foreign keys व link tables कैसे इस्तेमाल हों।
Derived attribute क्या है?
Derived attribute वो है जिसकी value दूसरे data से गणना की जा सकती है, सीधे store करने के बजाय। जैसे, age date of birth से derive हो सकती है, तो आप age बिल्कुल store न करें।
Relationship की degree क्या है?
Degree है कितनी entities relationship में भाग लेती हैं: unary (एक entity खुद से जुड़ी), binary (दो entities, सबसे आम), या ternary (तीन entities)। ज़्यादातर असली relationships binary हैं।
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

अगला topicDBMS में Functional Dependency आपकी प्रगति: 24 / 151 (16%) · Lesson 25 / 151 आगे बढ़ें →

यह lesson कैसा लगा?

आपकी राय से हम content और बेहतर बनाते हैं।

अपना review और सुझाव लिखें (वैकल्पिक)

Review approve होने के बाद आपका नाम और शहर इसके साथ public दिख सकते हैं। Email या phone न लिखें।

▶ CodingEasily on YouTube

Video से सीखें – आसान Hindi में

चुनी हुई video: RDBMS भाग 3 – Class XI Commerce IT

▶ Channel subscribe करें