Keys and Candidate-Key Constraints for (StudentName, StudentAge)(StudentName,\ StudentAge): Solving the “XX cannot be …” Problem

Keys and Candidate-Key Constraints for (StudentName, StudentAge)(StudentName,\ StudentAge): Solving the “XX cannot be …” Problem

Verified Sources
Sep 12, 2026

We are given a relation Students(StudentID, StudentName, StudentE-mail, StudentAge, CPI) with tuples:

StudentIDStudentNameStudentE-mailStudentAgeCPI
2345Shankarshankar@mathX9.4
1287Swatiswati@ee199.5
7853Shankarshankar@cse199.4
9876Swatiswati@mech189.3
8765Ganeshganesh@civil198.7

We are asked: for (StudentName, StudentAge)(StudentName,\ StudentAge) to be the key for this instance, the value XX should not be equal to: (i) 18, (ii) 19, (iii) 15, (iv) 20.

A key (and specifically the combination given) must satisfy uniqueness for that attribute set: no two different rows may have the same (StudentName,StudentAge)(StudentName, StudentAge) pair.

Key terms:

  • Key
  • Candidate Key
  • Uniqueness Constraint
  • Functional Dependency

Key idea

Check the existing (StudentName,StudentAge)(StudentName, StudentAge) pairs and see when a collision occurs.

Current pairs (ignoring StudentIDStudentID and CPI for key-check):

  • Tuple 1: (Shankar,X)(Shankar, X)
  • Tuple 2: (Swati,19)(Swati, 19)
  • Tuple 3: (Shankar,19)(Shankar, 19)
  • Tuple 4: (Swati,18)(Swati, 18)
  • Tuple 5: (Ganesh,19)(Ganesh, 19)

So, to keep (StudentName,StudentAge)(StudentName, StudentAge) as a key, (Shankar,X)(Shankar, X) must not equal any other existing pair.

A collision can only happen if:

  • (Shankar,X)=(Shankar,19)(Shankar, X) = (Shankar, 19), which implies X=19X = 19.

No other existing tuple has StudentName=ShankarStudentName = Shankar.

Thus, the only forbidden value among the options is X≠19X \ne 19, i.e., option (ii) 19.

Ensure $(StudentName, StudentAge)$ is a Key

  1. 1
    Step 1

    Extract (StudentName,StudentAge)(StudentName, StudentAge) from each tuple; the only unknown is the first tuple’s age XX.

  2. 2
    Step 2

    You obtain: (Swati,19)(Swati,19), (Shankar,19)(Shankar,19), (Swati,18)(Swati,18), (Ganesh,19)(Ganesh,19), plus (Shankar,X)(Shankar,X).

  3. 3
    Step 3

    A collision happens if (Shankar,X)(Shankar,X) equals an existing pair.

  4. 4
    Step 4

    Only (Shankar,19)(Shankar,19) has the same StudentName, so equality requires X=19X=19.

  5. 5
    Step 5

    Therefore, to keep uniqueness, XX should not be 1919 (option (ii)).

Pro Tip

When checking if an attribute set is a key, ignore all non-key attributes and focus purely on whether the key-attribute values are unique across rows. If any two rows share the same key-attribute values, it’s not a key.

Common Mistake

Don’t use StudentIDStudentID uniqueness to decide keyness. Even if StudentIDStudentID is unique, (StudentName,StudentAge)(StudentName, StudentAge) still must be unique by its own values.

Mental Workflow for Key-Constraint Problems

Extract

Step A

Write the value pairs/tuples for the proposed key attributes."

Compare

Step B

Look for identical pairs among rows."

Solve Constraint

Step C

If an unknown exists (here XX), compute the values that would cause a collision."

Pick the Option

Step D

Select the option value that must be excluded to maintain uniqueness."

Collision Check for XX with Existing Pair (Shankar,19)(Shankar,19)

If X=19X=19, then (Shankar,X)=(Shankar,19)(Shankar,X)=(Shankar,19) collides and violates key uniqueness.

Why other values are fine

Knowledge Check

Question 1 of 4
Q1Single choice

For (StudentName,StudentAge)(StudentName, StudentAge) to be a key, what must be true for any two tuples?