Sobes.tech
Junior — Middle

What are the main characteristics that a primary key in a database can have?

sobes.tech AI

Answer from AI

Main characteristics of a primary key in a database:

  • Uniqueness: each primary key value must be unique to unambiguously identify a record.
  • Cannot be NULL: the primary key must have a value; NULL is not allowed.
  • Immutability: primary key values usually do not change after record creation.
  • Simplicity: it is recommended to use a simple data type (e.g., numeric or string identifier).
  • Indexability: an index is automatically created on the primary key for fast searching.

Example in SQL:

CREATE TABLE users (
  id INT PRIMARY KEY,
  name VARCHAR(100)
);
What are the main characteristics that a primary key… - sobes.tech