← Back to Glossary

Composite key

A composite key is a primary key made up of two or more columns whose combined values uniquely identify a row, used when no single column is unique on its own.

Overview

A composite key (also called a compound key) combines multiple columns into a single primary key, because no individual column is unique by itself but the combination is. A classic example is a bridge table linking students to courses: neither student_id nor course_id alone identifies a row, but the pair (student_id, course_id) does.

Composite keys show up often in junction/bridge tables that resolve many-to-many relationships, in fact tables at a fine grain (e.g., order_id + line_number), and in time-series data where uniqueness requires both an entity identifier and a timestamp.

Related terms

FAQS

Composite keys work well for bridge/junction tables and fine-grained fact tables where the natural uniqueness genuinely spans two or more columns. Many teams still add a single surrogate key on top for simpler downstream joins, keeping the composite columns as a unique constraint.