Q.Which two constraints when applied together will produce a Primary Key constraint?
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Concept understanding — Unique Not Null
Unique Not Null: A Concept-First Explanation
Think about your Aadhaar number. Every citizen gets exactly one, and no two people share the same number. But here's the catch — you must have one. You cannot leave that field blank. That is the essence of Unique Not Null.
The Everyday Intuition
Imagine you are maintaining a class register. You want to record each student's roll number. Two things are obvious: every student must have a roll number (you cannot leave it empty), and no two students can share the same roll number. That is a Unique Not Null constraint in action.
Now contrast this with a student's phone number. Some students may not have one — that field can be left blank. And two siblings in the same class might share a phone number. So phone number is neither unique nor mandatory. The difference is intuitive once you see it.
The Precise Meaning
Unique means that within a given column (or set of columns), every value must be distinct from every other value. No duplicates allowed. Not Null means that the column cannot be left empty — it must contain a value. When you combine the two, you get a column where:
- Every row must have a value (no blanks)
- Every value must be different from every other value in that column
Unique Not Null is not the same as a Primary Key, though they look similar. A table can have only one Primary Key, but it can have multiple columns with Unique Not Null. Also, a Primary Key automatically enforces both uniqueness and non-nullness — but the reverse is not true. A Unique Not Null column does not automatically become the table's primary identifier.
Why It Matters
In real-world data, certain pieces of information are both mandatory and naturally unique. Consider these examples:
- Employee ID in a company database: every employee must have one, and no two employees can share the same ID
- PAN Card number in a tax database: mandatory for taxpayers, and unique by law
- Email address in a user registration system: every user must provide one, and no two accounts can share the same email
If you allowed duplicates in such columns, you would create confusion — two employees with the same ID, or two taxpayers with the same PAN. If you allowed blanks, you would have records that cannot be identified at all. …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.