Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Primary key

The Primary Key (PK) is the set of fields that uniquely identify a row in your table.

Concrete examples:

Daily metrics table (fact table)

Primary Key: (date, campaign_id, ad_id)
date
campaign_id
ad_id
impressions
clicks

2025-01-15

camp_123

ad_456

1000

50

2025-01-15

camp_123

ad_789

800

30

Each combination (date + campaign_id + ad_id) identifies a unique row.

Campaign attributes table (dimension table)

Primary Key: (campaign_id)
campaign_id
name
status
budget

camp_123

Summer Campaign

ACTIVE

5000

camp_456

Winter Campaign

PAUSED

3000

Each campaign_id identifies a unique campaign.

Why is this important?

The Primary Key concept allows you to define which table attributes identify each row as unique. This is essential for:

  • Determining the behavior of the UPSERT method: should an existing row be updated or should a new row be inserted?

  • Avoiding duplicates in your tables

  • Guaranteeing the uniqueness of each row and data integrity, two essential concepts in data management