In a relational table, which constraint ensures that no two rows have the same value for a key attribute?

Prepare for the GATE General Aptitude and CS Test. Enhance your skills with multiple choice questions and detailed explanations. Elevate your readiness and boost your confidence for the exam!

Multiple Choice

In a relational table, which constraint ensures that no two rows have the same value for a key attribute?

Explanation:
Key values in a table row must uniquely identify that row. A primary key provides that guarantee by enforcing that every row has a distinct value for the key and, by design, disallows nulls. This combination ensures no two rows share the same key value and every row can be uniquely identified. A unique constraint also enforces uniqueness, but in many databases it may allow nulls, so it doesn't always guarantee a non-null unique value for every row. A foreign key, on the other hand, enforces a relationship to another table, not uniqueness within the same table. An index speeds up searches but does not by itself enforce uniqueness unless it’s defined as unique.

Key values in a table row must uniquely identify that row. A primary key provides that guarantee by enforcing that every row has a distinct value for the key and, by design, disallows nulls. This combination ensures no two rows share the same key value and every row can be uniquely identified.

A unique constraint also enforces uniqueness, but in many databases it may allow nulls, so it doesn't always guarantee a non-null unique value for every row. A foreign key, on the other hand, enforces a relationship to another table, not uniqueness within the same table. An index speeds up searches but does not by itself enforce uniqueness unless it’s defined as unique.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy