PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम Integrity Constraints: Domain Integrity and Entity Integrity Constraints (इंटीग्रिटी प्रतिबंध: डोमेन अखंडता और एंटिटी अखंडता नियम) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।
Overview: Integrity Constraints act as database-enforced guardrails guaranteeing data accuracy, validity, and consistency across schema updates. Domain Integrity restricts column values to permissible atomic domains, whereas Entity Integrity mandates that no attribute of a Primary Key may ever contain NULL.
अध्याय सार: इंटीग्रिटी प्रतिबंध (Integrity Constraints) डेटाबेस में डेटा की शुद्धता, वैधता और संगति बनाए रखने वाले अनिवार्य नियम हैं। डोमेन अखंडता (Domain Integrity) प्रत्येक कॉलम के मान को वैध सीमा और प्रकार तक सीमित करती है, जबकि एंटिटी अखंडता (Entity Integrity) कहती है कि प्राइमरी की का कोई भी भाग NULL नहीं हो सकता।
Integrity Constraints: Domain Integrity and Entity Integrity Constraints: Detailed Notes & Architecture (इंटीग्रिटी प्रतिबंध: डोमेन अखंडता और एंटिटी अखंडता नियम)
1. Classification of Relational Integrity Constraints (रिलेशनल इंटीग्रिटी प्रतिबंधों का वर्गीकरण)
[EN] Elmasri & Navathe categorize relational constraints into three groups: Inherent Model-Based Constraints (no duplicate tuples, atomic 1NF cells), Schema-Based Constraints explicitly declared in DDL (Domain, Key, Entity Integrity, and Referential Integrity constraints), and Application-Based / Semantic Constraints enforced by triggers or assertions (e.g., 'Employee salary cannot exceed supervisor salary'). Whenever an INSERT, UPDATE, or DELETE violates any constraint, the DBMS aborts the offending modification to protect database consistency.
[HI] रिलेशनल मॉडल में अखंडता नियमों को तीन श्रेणियों में बांटा जाता है: अंतर्निहित मॉडल नियम (जैसे परमाणु मान व अद्वितीय पंक्तियाँ), स्कीमा-आधारित नियम (डोमेन, की, एंटिटी व संदर्भात्मक अखंडता जो DDL में लिखे जाते हैं), और एप्लिकेशन/सिमेंटिक नियम (व्यावसायिक तर्क जैसे कर्मचारी का वेतन मैनेजर से अधिक न हो)। किसी भी नियम का उल्लंघन होने पर DBMS उस DML ऑपरेशन को अस्वीकार कर देता है।
2. Domain Integrity Constraint (Data Type, Range & Format Rules) (डोमेन अखंडता (Domain Integrity): मान व प्रारूप नियम)
[EN] The Domain Integrity Constraint requires that every attribute value inside a tuple must be an atomic element strictly belonging to the declared domain Dom(A) (or NULL, if permitted). It governs data type, character length, value bounds, enumeration lists, and formatting. In SQL DDL, Domain Integrity is enforced via column Data Types (INT, DATE, VARCHAR(50)), NOT NULL, DEFAULT, CHECK constraints (e.g., CHECK (Age >= 18 AND Age <= 65)), ENUM types, and reusable CREATE DOMAIN definitions.
[HI] डोमेन अखंडता नियम यह सुनिश्चित करता है कि प्रत्येक कॉलम में भरा जाने वाला मान केवल उसी के निर्धारित डोमेन (वैध डेटा प्रकार, लंबाई, रेंज और प्रारूप) से लिया गया परमाणु मान हो। SQL में इसे डेटा टाइप्स (INT, DECIMAL, DATE), CHECK प्रतिबंध (जैसे CHECK (Marks BETWEEN 0 AND 100)), NOT NULL, DEFAULT, ENUM और CREATE DOMAIN कथन द्वारा लागू किया जाता है।
3. Entity Integrity Constraint (Primary Key NOT NULL Rule) (एंटिटी अखंडता (Entity Integrity): प्राइमरी की NOT NULL नियम)
[EN] Formulated in E.F. Codd's foundational relational rules, the Entity Integrity Constraint states that NO Primary Key value—and NO single component attribute of a composite Primary Key—can be NULL. The rationale is logical: every Primary Key exists to uniquely identify an individual real-world entity tuple; allowing NULL ('unknown') would mean having an entity whose identity cannot be determined or compared against other entities! Note that Entity Integrity applies specifically to Primary Keys (Alternate Keys may allow NULL if NOT NULL is omitted).
[HI] ई.एफ. कॉड के मूल नियमों पर आधारित एंटिटी अखंडता नियम कहता है कि किसी भी रिलेशन की प्राइमरी की (तथा कंपोजिट प्राइमरी की के किसी भी कॉलम) का मान कभी भी NULL नहीं हो सकता। इसका तार्किक कारण यह है कि प्राइमरी की हर रिकॉर्ड की स्वतंत्र पहचान करती है—यदि वही 'अज्ञात' (NULL) हो जाए, तो उस एंटिटी की पहचान और तुलना करना असंभव हो जाएगा।
4. Key Constraint & Semantic/Enterprise Constraints (Triggers & Assertions) (की प्रतिबंध व व्यावसायिक सिमेंटिक नियम (Triggers / Assertions))
[EN] Key Constraints (distinct from Entity Integrity) enforce Uniqueness across Super Keys, Candidate Keys, Primary Keys, and UNIQUE Alternate Keys so no two tuples share identical key values. Beyond single-row CHECK constraints, complex multi-row or cross-table business rules—known as Semantic Integrity Constraints—cannot always be captured by standard key/domain syntax and are enforced using SQL CREATE ASSERTION (general predicate check across tables) or event-driven CREATE TRIGGER (BEFORE/AFTER INSERT/UPDATE/DELETE) procedures.
[HI] की प्रतिबंध (Key Constraint) सुनिश्चित करता है कि किसी भी दो पंक्तियों की प्राइमरी की या UNIQUE की समान न हो। वहीं एक से अधिक पंक्तियों या टेबल्स से जुड़े जटिल व्यावसायिक नियम—जिन्हें सिमेंटिक या एंटरप्राइज इंटीग्रिटी कहते हैं—सामान्य CHECK प्रतिबंध से लागू नहीं हो पाते; इन्हें लागू करने के लिए SQL में ASSERTION या TRIGGER (BEFORE/AFTER INSERT/UPDATE) का उपयोग किया जाता है।
Syntax, Formula & Technical Example (Integrity Constraints: Domain Integrity and Entity Integrity Constraints)
-- Demonstrating Domain, Entity, Key, and Referential Integrity Constraints together
CREATE DOMAIN EmailStr AS VARCHAR(120) CHECK (VALUE LIKE '%@%.%');
CREATE TABLE Candidate (
Cand_ID INT PRIMARY KEY, -- Entity Integrity (NOT NULL) + Key Constraint (UNIQUE)
Full_Name VARCHAR(60) NOT NULL, -- Domain Integrity (Non-null string)
Age INT CHECK (Age BETWEEN 18 AND 40), -- Domain Integrity (Valid age range)
Email EmailStr UNIQUE, -- Domain Format + Key Uniqueness
Exam_Fee DECIMAL(6,2) DEFAULT 500.00 CHECK (Exam_Fee >= 0)
);
Integrity Constraints: Domain Integrity and Entity Integrity Constraints Quick Reference & Comparison Table
| Integrity Constraint Type | Core Enforced Rule | Primary SQL Mechanism |
|---|---|---|
| Domain Integrity | Column values must match valid atomic type/range | Data types, CHECK, NOT NULL, DEFAULT, CREATE DOMAIN |
| Entity Integrity | No attribute of Primary Key may contain NULL | PRIMARY KEY (automatically enforces NOT NULL) |
| Key Constraint | No two tuples may share identical PK/Unique values | PRIMARY KEY and UNIQUE constraints |
| Referential Integrity | Non-null FK must match existing Parent Key value | FOREIGN KEY ... REFERENCES ... ON DELETE/UPDATE |
Integrity Constraints: Domain Integrity and Entity Integrity Constraints Top 20 Bilingual MCQs with Answers
Q1. What does the Entity Integrity Constraint strictly mandate in a relational database?
(रिलेशनल डेटाबेस में एंटिटी इंटीग्रिटी (Entity Integrity) प्रतिबंध सख्ती से क्या अनिवार्य करता है?)
(A) Every Foreign Key must be NOT NULL
(B) No attribute forming part of a Primary Key can contain a NULL value
(C) Every table must have at least two Candidate Keys
(D) Every column in a table must hold integer values
Correct Answer: (B)
[EN] Entity Integrity ensures every row is identifiable by forbidding NULL in any Primary Key column (simple or composite).
[HI] एंटिटी इंटीग्रिटी के अनुसार किसी भी प्राइमरी की या उसके किसी भी हिस्से में NULL मान नहीं हो सकता।
Q2. What does the Domain Integrity Constraint restrict in a relational table?
(रिलेशनल टेबल में डोमेन इंटीग्रिटी (Domain Integrity) प्रतिबंध किसे नियंत्रित करता है?)
(A) Only the count of columns in a schema
(B) Only cross-table joins between parent and child
(C) Each attribute value must be atomic and belong to the valid data type, range, and format defined for that column
(D) Only user login passwords
Correct Answer: (C)
[EN] Domain integrity guarantees every cell holds a permissible atomic value from its column's specified domain.
[HI] डोमेन अखंडता सुनिश्चित करती है कि प्रत्येक कॉलम में केवल उसके निर्धारित डेटा टाइप, रेंज और प्रारूप के अनुसार ही परमाणु मान डाला जाए।
Q3. Which SQL constraint is specifically used to enforce a Domain Integrity value-range rule such as 'Marks must be between 0 and 100'?
('Marks का मान 0 से 100 के बीच ही होना चाहिए'—इस डोमेन इंटीग्रिटी नियम को लागू करने के लिए कौन सा SQL प्रतिबंध उपयुक्त है?)
(A) FOREIGN KEY (Marks)
(B) UNIQUE (Marks)
(C) CHECK (Marks BETWEEN 0 AND 100)
(D) PRIMARY KEY (Marks)
Correct Answer: (C)
[EN] The CHECK constraint evaluates a boolean domain predicate on every inserted or updated row.
[HI] कॉलम के मान की सीमा जांचने के लिए SQL में CHECK प्रतिबंध का उपयोग किया जाता है।
Q4. Inserting NULL into a NON-KEY column marked NOT NULL (e.g., Customer_Name VARCHAR(50) NOT NULL) violates which integrity constraint?
(किसी गैर-की कॉलम (जैसे Customer_Name NOT NULL) में NULL मान डालने की कोशिश करने पर कौन सी अखंडता भंग होती है?)
(A) Domain Integrity Constraint
(B) Referential Integrity Constraint
(C) Entity Integrity Constraint
(D) Tuple Ordering Constraint
Correct Answer: (A)
[EN] Entity Integrity specifically governs Primary Keys; NOT NULL on an ordinary attribute is part of its Domain Integrity definition.
[HI] एंटिटी अखंडता केवल प्राइमरी की से संबंधित है; किसी सामान्य कॉलम पर NOT NULL लगना उसकी डोमेन अखंडता का हिस्सा होता है।
Q5. Inserting a tuple with Primary Key = NULL violates which constraint?
(यदि किसी नई पंक्ति में प्राइमरी की का मान NULL रखा जाए, तो कौन सा नियम भंग होता है?)
(A) Entity Integrity Constraint
(B) Referential Integrity Constraint
(C) 2NF Decomposition
(D) Functional Dependency Rule
Correct Answer: (A)
[EN] By definition, NULL inside a Primary Key directly violates Entity Integrity.
[HI] प्राइमरी की में NULL डालने से सीधे एंटिटी इंटीग्रिटी नियम का उल्लंघन होता है।
Q6. Inserting a duplicate Primary Key value (e.g., two students both having Roll_No = 105) directly violates which constraint?
(दो अलग छात्रों को एक ही प्राइमरी की मान (Roll_No = 105) देने पर कौन सा प्रतिबंध टूटता है?)
(A) Key Constraint (Uniqueness constraint)
(B) Atomic 1NF Constraint
(C) Referential Integrity Constraint
(D) Domain Data Type Constraint
Correct Answer: (A)
[EN] Key constraint mandates that all tuples possess distinct Primary Key / Unique values; Entity Integrity specifically refers to the NOT NULL rule on PK.
[HI] दो पंक्तियों में एक समान प्राइमरी की होना Key (Uniqueness) प्रतिबंध का उल्लंघन है, जबकि NULL होना एंटिटी इंटीग्रिटी का।
Q7. Why is the Entity Integrity Constraint necessary in Codd's Relational Model?
(कॉड के रिलेशनल मॉडल में एंटिटी इंटीग्रिटी नियम की आवश्यकता क्यों पड़ी?)
(A) To automatically compress numeric columns
(B) To make sure strings are stored in uppercase
(C) To force every table to have 10 columns
(D) Because if a Primary Key were NULL, an entity could not be uniquely identified or compared reliably in joins/references
Correct Answer: (D)
[EN] NULL denotes unknown; an unknown PK makes entity identity and foreign-key referencing impossible.
[HI] यदि प्राइमरी की ही अज्ञात (NULL) होगी, तो किसी रिकॉर्ड की पहचान करना और उसे फॉरेन की से जोड़ना संभव नहीं रह जाएगा।
Q8. Suppose a table has Composite Primary Key (Order_ID, Line_No). Which tuple violates Entity Integrity?
(यदि किसी टेबल की कंपोजिट प्राइमरी की (Order_ID, Line_No) हो, तो कौन सा टपल एंटिटी इंटीग्रिटी का उल्लंघन करेगा?)
(A) (5001, NULL)
(B) (5002, 1)
(C) (5003, 99)
(D) (5001, 1) followed by (5001, 2)
Correct Answer: (A)
[EN] Entity Integrity forbids NULL in EVERY component attribute of a composite PK, so (5001, NULL) is invalid.
[HI] कंपोजिट प्राइमरी की के किसी एक भाग में भी NULL आना (जैसे (5001, NULL)) एंटिटी इंटीग्रिटी का उल्लंघन है।
Q9. Attempting to insert 'ABC' into an integer column Age INT violates which constraint?
(Age INT जैसे पूर्णांक कॉलम में 'ABC' टेक्स्ट डालने का प्रयास करने से कौन सा प्रतिबंध टूटता है?)
(A) Referential Integrity Constraint
(B) Domain Integrity Constraint
(C) Cascade Constraint
(D) Entity Integrity Constraint
Correct Answer: (B)
[EN] Data types define a column's fundamental value domain; passing text into an INT column violates Domain Integrity.
[HI] किसी कॉलम में गलत डेटा टाइप ('ABC' को INT में) डालना डोमेन अखंडता का सीधा उल्लंघन है।
Q10. Which SQL DDL statement creates a reusable named Domain definition with custom validation rules across multiple tables?
(कौन सी SQL DDL कमांड एक से अधिक टेबल्स में पुनः उपयोग होने वाला नामित डोमेन नियम बनाती है?)
(A) CREATE DOMAIN
(B) CREATE SCHEMA
(C) CREATE CURSOR
(D) CREATE TRIGGER
Correct Answer: (A)
[EN] ANSI SQL provides CREATE DOMAIN <name> AS <type> CHECK (...) to share consistent domain integrity rules across tables.
[HI] मानक SQL में CREATE DOMAIN कथन द्वारा एक बार वैधता नियम तय कर कई टेबल्स में उपयोग किया जा सकता है।
Q11. What SQL mechanism is typically required to enforce a cross-table Semantic/Enterprise Constraint like 'Total project budget must not exceed Department annual limit'?
('सभी प्रोजेक्ट्स का कुल बजट विभाग की वार्षिक सीमा से अधिक नहीं होना चाहिए'—इस क्रॉस-टेबल नियम को लागू करने हेतु SQL में क्या उपयोग होता है?)
(A) Column-level DEFAULT constraint
(B) PRIMARY KEY alone
(C) CREATE ASSERTION or CREATE TRIGGER
(D) ORDER BY clause
Correct Answer: (C)
[EN] Single-row CHECK constraints cannot inspect aggregates across tables; Assertions or Triggers handle complex semantic rules.
[HI] विभिन्न टेबल्स या पंक्तियों के योग पर आधारित नियम सामान्य CHECK से नहीं हो सकते; इनके लिए ASSERTION या TRIGGER चाहिए।
Q12. In SQL, what happens to an INSERT statement that fails a CHECK constraint such as CHECK (Salary > 0) when Salary = -500?
(यदि किसी टेबल में CHECK (Salary > 0) लगा हो और Salary = -500 डालकर INSERT चलाया जाए, तो क्या होगा?)
(A) The DBMS sets Salary to NULL silently
(B) The DBMS automatically converts -500 to +500
(C) The CHECK rule is ignored unless a Trigger exists
(D) The DBMS rejects the INSERT statement and raises a check constraint violation error
Correct Answer: (D)
[EN] Whenever a check constraint evaluates to FALSE, the DBMS aborts the DML statement.
[HI] शर्त FALSE होने पर DBMS उस INSERT कमांड को अस्वीकार कर देता है और त्रुटि संदेश दिखाता है।
Q13. In SQL three-valued logic (TRUE, FALSE, UNKNOWN), does inserting NULL into a column with CHECK (Age >= 18) (without NOT NULL) fail the CHECK constraint?
(SQL के त्रि-स्तरीय तर्क में यदि केवल CHECK (Age >= 18) लगा हो (NOT NULL नहीं), तो क्या Age = NULL डालना CHECK प्रतिबंध से रुक पाएगा?)
(A) CHECK converts NULL into 18
(B) Yes—NULL evaluates to 0 which is < 18
(C) Yes—CHECK always rejects NULL automatically
(D) No—because (NULL >= 18) evaluates to UNKNOWN, and SQL CHECK constraints reject rows ONLY when the expression evaluates to FALSE!
Correct Answer: (D)
[EN] Classic SQL exam trap: CHECK passes if the condition is TRUE or UNKNOWN! You MUST add NOT NULL if NULL should be rejected.
[HI] महत्वपूर्ण परीक्षा तथ्य: SQL में CHECK केवल FALSE आने पर ही रोकता है; NULL >= 18 का परिणाम UNKNOWN आने से बिना NOT NULL के NULL पास हो जाएगा!
Q14. Which category of constraints includes rules inherent to the Relational Model itself—such as 'No two tuples can be identical' and 'Attributes must be atomic'?
(रिलेशनल मॉडल में स्वयं निहित नियमों—जैसे 'दो पंक्तियाँ समान नहीं होंगी' व 'कॉलम मान परमाणु होंगे'—को किस श्रेणी में रखा जाता है?)
(A) Referential Cascade Rules
(B) Inherent Model-Based Constraints
(C) User-Defined Stored Procedures
(D) Application Triggers
Correct Answer: (B)
[EN] Inherent constraints are built directly into the relational data model rather than declared explicitly per table.
[HI] ये नियम मॉडल की मूल प्रकृति में ही निहित होते हैं, अतः इन्हें Inherent Model-Based Constraints कहते हैं।
Q15. Which pair matches 'Domain Integrity' and 'Entity Integrity' accurately?
(डोमेन इंटीग्रिटी और एंटिटी इंटीग्रिटी का बिल्कुल सही मिलान किस विकल्प में है?)
(A) Domain Integrity -> Valid column values/types; Entity Integrity -> Primary Key cannot be NULL
(B) Domain Integrity -> Table row count; Entity Integrity -> Column count
(C) Domain Integrity -> Cascade Delete; Entity Integrity -> Triggers
(D) Domain Integrity -> Primary Key cannot be NULL; Entity Integrity -> Valid foreign keys
Correct Answer: (A)
[EN] Domain governs legal attribute value sets; Entity governs non-null Primary Key identification.
[HI] डोमेन इंटीग्रिटी कॉलम के वैध मान तय करती है और एंटिटी इंटीग्रिटी प्राइमरी की के NOT NULL होने की गारंटी देती है।
Q16. Which statement about Integrity Constraints is FALSE?
(इंटीग्रिटी प्रतिबंधों के बारे में निम्नलिखित में से कौन सा कथन असत्य (FALSE) है?)
(A) Key Constraints forbid duplicate Primary Key values across tuples
(B) Referential Integrity prevents orphan child records pointing to missing parent keys
(C) Entity Integrity forbids NULL values in Foreign Key columns as well as Primary Keys
(D) Domain Integrity checks that attribute values come from their declared domain
Correct Answer: (C)
[EN] Entity Integrity restricts Primary Keys ONLY; Foreign Keys are allowed to contain NULL values unless explicitly forbidden.
[HI] एंटिटी इंटीग्रिटी केवल प्राइमरी की पर लागू होती है, फॉरेन की में NULL मान आ सकते हैं।
Q17. Within Integrity Constraints: Domain Integrity and Entity Integrity Constraints, which integrity constraint type directly maps to: "Column values must match valid atomic type/range"?
(Integrity Constraints: Domain Integrity and Entity Integrity Constraints में कौन सा Integrity Constraint Type सीधे "Column values must match valid atomic type/range" से संबंधित है?)
(A) Referential Integrity
(B) Domain Integrity
(C) Entity Integrity
(D) Key Constraint
Correct Answer: (B)
[EN] In Integrity Constraints: Domain Integrity and Entity Integrity Constraints, 'Domain Integrity' handles 'Column values must match valid atomic type/range' (Data types, CHECK, NOT NULL, DEFAULT, CREATE DOMAIN).
[HI] Integrity Constraints: Domain Integrity and Entity Integrity Constraints में 'Domain Integrity' का कार्य/विवरण 'Column values must match valid atomic type/range' (Data types, CHECK, NOT NULL, DEFAULT, CREATE DOMAIN) है।
Q18. Which option accurately describes 'Entity Integrity' in Integrity Constraints: Domain Integrity and Entity Integrity Constraints?
(Integrity Constraints: Domain Integrity and Entity Integrity Constraints के संदर्भ में 'Entity Integrity' की सही विशेषता कौन सी है?)
(A) No attribute of Primary Key may contain NULL
(B) No two tuples may share identical PK/Unique values
(C) Non-null FK must match existing Parent Key value
(D) Column values must match valid atomic type/range
Correct Answer: (A)
[EN] 'Entity Integrity' provides 'No attribute of Primary Key may contain NULL' — key point: PRIMARY KEY (automatically enforces NOT NULL).
[HI] 'Entity Integrity' का मुख्य विवरण 'No attribute of Primary Key may contain NULL' है (PRIMARY KEY (automatically enforces NOT NULL))।
Q19. In Integrity Constraints: Domain Integrity and Entity Integrity Constraints, identify the correct parameter for the specification: "No two tuples may share identical PK/Unique values".
(Integrity Constraints: Domain Integrity and Entity Integrity Constraints में "No two tuples may share identical PK/Unique values" विवरण किस विकल्प के लिए सही है?)
(A) Domain Integrity
(B) Entity Integrity
(C) Key Constraint
(D) Referential Integrity
Correct Answer: (C)
[EN] 'Key Constraint' corresponds to 'No two tuples may share identical PK/Unique values' (PRIMARY KEY and UNIQUE constraints).
[HI] 'Key Constraint' का संबंध 'No two tuples may share identical PK/Unique values' (PRIMARY KEY and UNIQUE constraints) से है।
Q20. Considering Integrity Constraints: Domain Integrity and Entity Integrity Constraints, what key behavior defines 'Referential Integrity'?
(Integrity Constraints: Domain Integrity and Entity Integrity Constraints में 'Referential Integrity' की मुख्य भूमिका या मान क्या है?)
(A) No attribute of Primary Key may contain NULL
(B) Non-null FK must match existing Parent Key value
(C) Column values must match valid atomic type/range
(D) No two tuples may share identical PK/Unique values
Correct Answer: (B)
[EN] 'Referential Integrity' represents 'Non-null FK must match existing Parent Key value' (FOREIGN KEY ... REFERENCES ... ON DELETE/UPDATE).
[HI] 'Referential Integrity' का अर्थ/मान 'Non-null FK must match existing Parent Key value' है (FOREIGN KEY ... REFERENCES ... ON DELETE/UPDATE)।
Integrity Constraints: Domain Integrity and Entity Integrity Constraints — Exam FAQs
Q1: What is the difference between Key Constraint and Entity Integrity Constraint?
की प्रतिबंध (Key Constraint) और एंटिटी इंटीग्रिटी प्रतिबंध में क्या मुख्य अंतर है?
[EN] Key Constraint ensures UNIQUENESS (no two rows have the same Primary Key or Candidate Key value), whereas Entity Integrity specifically ensures NON-NULLABILITY (no attribute of the Primary Key can be NULL).
[HI] की प्रतिबंध अद्वितीयता (Uniqueness—दो पंक्तियाँ समान PK न रखें) सुनिश्चित करता है, जबकि एंटिटी इंटीग्रिटी शून्यता-निषेध (प्राइमरी की कभी NULL न हो) लागू करती है।
Q2: Why did my CHECK (Score >= 0) constraint still allow a NULL value in SQL?
SQL में CHECK (Score >= 0) लगाने के बाद भी कॉलम में NULL कैसे स्वीकार हो गया?
[EN] Because in SQL three-valued logic, 'NULL >= 0' evaluates to UNKNOWN rather than FALSE, and CHECK constraints only block operations that evaluate to FALSE. Always add NOT NULL alongside CHECK if NULLs are unwanted.
[HI] क्योंकि SQL में 'NULL >= 0' का मान FALSE नहीं बल्कि UNKNOWN होता है, और CHECK प्रतिबंध केवल FALSE होने पर रोकता है। NULL रोकने हेतु NOT NULL भी लगाएं।
Q3: Are Integrity Constraints checked only during table creation or on every update?
क्या इंटीग्रिटी प्रतिबंध केवल टेबल बनाते समय जांचे जाते हैं या डेटा बदलते समय भी?
[EN] They are declared once in DDL (CREATE/ALTER TABLE) and then automatically enforced by the DBMS on EVERY subsequent INSERT, UPDATE, and DELETE statement.
[HI] इन्हें टेबल बनाते समय DDL में घोषित किया जाता है, लेकिन उसके बाद प्रत्येक INSERT, UPDATE और DELETE कमांड पर DBMS इनकी सख्ती से जांच करता है।
Post a Comment
Post a Comment