DA0-001 · Question #155
Which of the following is a difference between a primary key and a unique key?
The correct answer is B. There can be only one primary key in a data set, whereas there can be multiple unique keys. A key difference between a primary key and a unique key is that a table can have only one primary key, while it can have multiple unique keys.
Question
Which of the following is a difference between a primary key and a unique key?
Options
- AA unique key cannot take null values, whereas a primary key can take null values.
- BThere can be only one primary key in a data set, whereas there can be multiple unique keys.
- CA primary key can take a value more than once, whereas a unique key cannot take a value more
- DA primary key cannot be a date variable, whereas a unique key can be.
How the community answered
(49 responses)- A2% (1)
- B92% (45)
- C2% (1)
- D4% (2)
Why each option
A key difference between a primary key and a unique key is that a table can have only one primary key, while it can have multiple unique keys.
This is incorrect; primary keys cannot take null values, and unique keys can often take a single null value.
A table can have only one primary key, which serves as the principal identifier for each record and must contain unique, non-null values. In contrast, a table can have multiple unique keys, which enforce uniqueness on specific columns but can typically allow a single NULL value (depending on the database system).
This is incorrect; both primary keys and unique keys enforce uniqueness, meaning values cannot appear more than once (except for the single NULL allowance for unique keys).
Both primary and unique keys can be composed of various data types, including date variables, as long as they meet the uniqueness and nullability constraints.
Concept tested: Primary key vs. Unique key
Source: learn.microsoft.com/en-us/sql/relational-databases/tables/primary-and-foreign-key-constraints?view=sql-server-ver16
Topics
Community Discussion
No community discussion yet for this question.