nerdexam
CompTIA

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.

Data Concepts and Environments

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)
  • A
    2% (1)
  • B
    92% (45)
  • C
    2% (1)
  • D
    4% (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.

AA unique key cannot take null values, whereas a primary key can take null values.

This is incorrect; primary keys cannot take null values, and unique keys can often take a single null value.

BThere can be only one primary key in a data set, whereas there can be multiple unique keys.Correct

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).

CA primary key can take a value more than once, whereas a unique key cannot take a value more

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).

DA primary key cannot be a date variable, whereas a unique key can be.

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

#Primary Key#Unique Key#Database Concepts#Data Integrity

Community Discussion

No community discussion yet for this question.

Full DA0-001 Practice