Beginner

137. Surrogate Key

Understand how artificially generated identifiers are used as database keys.

📘 Lesson 137 of 728 ⏱ 9 min 🎯 Intermediate

A surrogate key is an artificially generated identifier that has no direct business meaning. It is commonly generated as an integer or other system-managed value.

Surrogate keys can provide stable, simple identifiers even when business attributes are long, complex, or subject to change.

CustomerID 1001 can be generated by the database and used as the identifier for a customer whose business information may change.

SQL
CREATE TABLE Customers (
    CustomerID INT PRIMARY KEY,
    CustomerName VARCHAR(100),
    Email VARCHAR(150)
);

Surrogate keys are widely used in relational databases, data warehouses, dimension tables, and analytical systems.

  • Surrogate keys are generated identifiers.
  • They normally have no business meaning.
  • They can provide stable relationships.
  • They are common in data warehouses.
  • They can simplify joins and indexing.
What is a surrogate key?

A surrogate key is an artificially generated identifier used to uniquely identify a record.

Why use a surrogate key?

It provides a simple and stable identifier that does not depend on changing business attributes.

Have you finished this lesson?

Introduction to SQL – All Lessons