What is Primary Key?

Turkish: Primary Key

A primary key is a non-null, non-repeating column or column set that uniquely identifies each row in a database table.

What is a Primary Key?

A primary key is the main identifier that lets a database find rows without ambiguity. In a customer table, customer_id often plays this role; in an orders table, it may be order_id.

A primary key value must not be null and must not repeat inside the same table. The database enforces this rule as a constraint, and most systems create an index for the primary key so single-record lookups are fast.

Types

  • Surrogate key: A technical identifier with no business meaning, often an auto-incrementing number or UUID.
  • Natural key: An identifier that comes from business data, such as email, tax number, or SKU; its change risk must be evaluated.
  • Composite key: A key where multiple columns are unique together, such as order_id + product_id.

Business Use

Primary key selection directly affects reporting, integration, data migration, and audit log design. If a changeable field becomes the primary key, references in external systems can break; if random UUIDs are used, ordering behavior and index size should be considered.

Reliable foreign key relationships and accurate SQL queries both depend on clear primary key design, making it one of the first decisions in a database model.