Skip to content
Think & Reflect · Q1

Q.Which two constraints when applied together will produce a Primary Key constraint?

Tripura TbseTextbookSubjective· 2mImportance★★★★★
52% · 49/95 Questions
🔒 Locked · start free trial →

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 →

A Primary Key constraint is functionally equivalent to applying both the UNIQUE and NOT NULL constraints together on a column or set of columns.

In database management systems, particularly in SQL, a Primary Key is a special column or a set of columns that uniquely identifies each row (or record) in a table. It serves as the unique identifier for each entity represented by a row.

The two fundamental properties of a Primary Key are:

  1. Uniqueness: No two rows can have the same value for the Primary Key.
  2. Non-nullability: The Primary Key column(s) cannot contain NULL values. Every row must have a definite value for its Primary Key.

Now, let's look at the two individual constraints that, when combined, enforce these properties:

1. The UNIQUE Constraint

The UNIQUE constraint ensures that all values in a column (or a group of columns) are distinct. This directly addresses the "uniqueness" property of a Primary Key. If you try to insert a row with a value that already exists in a column defined as UNIQUE, the database will reject the operation.

Note

While UNIQUE ensures distinct values, it typically allows for one NULL value in the column, as NULL is considered an unknown value and thus distinct from any other NULL value in some SQL implementations. However, for the purpose of a Primary Key, we need to disallow NULL entirely.

2. The NOT NULL Constraint

The NOT NULL constraint ensures that a column cannot store NULL values. This directly addresses the "non-nullability" property of a Primary Key. If you try to insert a row without providing a value for a column defined as NOT NULL, or explicitly try to set it to NULL, the database will reject the operation.

Combining UNIQUE and NOT NULL

When you apply both the UNIQUE and NOT NULL constraints to the same column (or set of columns), you effectively create a Primary Key.

  • The UNIQUE constraint guarantees that every value in that column is distinct.
  • The NOT NULL constraint guarantees that every row must have a value in that column, and that value cannot be NULL. …

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.