Microsoft Azure Data FundamentalsDescribe how to work with relational data on AzureEasy

A data engineer is working with an Azure SQL Database. The database stores sensor readings where each reading has a unique identifier that needs to be automatically generated and incremented for every new record. Which property should be assigned to the SensorID column to achieve this?

  1. AUNIQUE
  2. BPRIMARY KEY
  3. CIDENTITY
  4. DDEFAULT
Show answer & explanation

Correct answer: C. IDENTITY

The IDENTITY property automatically generates sequential numeric values for a column, which is precisely what's needed for an auto-incrementing unique identifier.

Why the other options are wrong

  • A. UNIQUE ensures that all values in a column are distinct, but it does not automatically generate values.
  • B. PRIMARY KEY ensures uniqueness and defines a clustered index, but it does not automatically generate values.
  • D. DEFAULT specifies a default value for a column when no value is explicitly provided during an INSERT, but it's not for auto-incrementing sequential IDs.

IDENTITY Property (SQL)

The IDENTITY property in SQL Server automatically generates sequential numeric values for a column when new rows are inserted into a table.

  • Auto-increments numeric values.
  • Guarantees uniqueness within the column.
  • Often used for primary key columns.

Memory trick: IDENTITY for Incremental ID.

More Describe how to work with relational data on Azure questions