Sobes.tech
Middle

What is a primary key and what are its properties?

sobes.tech AI

Answer from AI

A primary key is a unique identifier for a record in a database table. Its main properties:

  • Uniqueness: each primary key value is unique and does not repeat in the table.
  • Cannot be NULL: the primary key must have a value.
  • Stability: the primary key value should not change over time.

Example in SQL:

CREATE TABLE Users (
  UserID INT PRIMARY KEY,
  UserName VARCHAR(100)
);

Here, UserID is the primary key, uniquely identifying each user.

What is a primary key and what are its properties… - sobes.tech