Database Basics
In a relational database table, which condition must the column (or set of columns) designated as the primary key satisfy?
- AIts values must be numbers
- BIt must be the first column of the table
- CIts values must not be duplicated within the table and must not include NULL
Show answer and explanation
Answer: C. Its values must not be duplicated within the table and must not include NULL
A primary key is a column, or set of columns, used to uniquely identify one row in a table. Its values therefore must not duplicate those of any other row (uniqueness), and NULL, which represents an unknown value, is not allowed either (NOT NULL). When PRIMARY KEY is specified in an SQL CREATE TABLE statement, the DBMS (database management system) enforces these two constraints, and any operation that tries to insert a duplicate value or NULL fails with an error. A primary key may hold numbers such as employee numbers or character strings, and there is no rule about its column position. A minimal set of columns that can uniquely identify a row is called a candidate key, and the primary key is the one chosen from the candidate keys.
- A. A primary key can be a character string; it does not have to be a number.
- B. A primary key can be any column of the table; its position does not matter.
- C. Correct. Being unique and free of NULL are the conditions for a primary key.