Composite Keys

Introduction

A composite key is a key made up of two or more columns that, taken together, uniquely identify a row. No single column in the combination is unique on its own, but the combination is. Composite keys show up constantly in real schemas: in bridge (junction) tables that resolve many-to-many relationships, in line-item tables keyed by order number plus line number, and in any table where the natural identifier is genuinely multi-part.

In this module you are learning to tell key types apart and to write the constraints that enforce them. Composite keys are where that gets interesting, because the syntax changes: you can no longer declare the key inline next to a single column, so you use a table-level PRIMARY KEY (col1, col2) or UNIQUE (col1, col2) clause, or add it later with ALTER TABLE ... ADD CONSTRAINT. Foreign keys that point at a composite key must also list the matching columns in the same order.

As you watch, pay attention to three things: the exact placement and syntax of the table-level constraint, how the videos justify choosing a multi-column natural key instead of a single surrogate ID, and how a child table references a composite parent key. Also note the trade-offs mentioned — composite keys can enforce meaningful business rules, but they make joins wordier and propagate more columns into every referencing table.

Video 1: Primary key on two columns SQL Server

kudvenkat · 5:39 · 99,465 views · 5y ago · captions — Watch on YouTube

About this video

A short, demo-driven lesson on creating a primary key across two columns in SQL Server. Based on its title and description, it walks through a composite primary key example, showing the table-level syntax needed when the key spans more than one column, and likely demonstrates both the CREATE TABLE form and how uniqueness is enforced across the pair rather than each column individually.

Why this video

kudvenkat is a long-running, well-regarded SQL tutorial channel, and this video targets exactly the core mechanical skill in this topic: writing a composite PRIMARY KEY constraint in SQL.

Video 2: Entity Relationship Diagram (ERD) Tutorial - Part 2: Primary keys, foreign keys, and bridge tables

Lucid Software · 14:44 · 383,890 views · 2y ago · captions — Watch on YouTube

About this video

Part 2 of Lucid Software's ERD tutorial series, covering primary keys, foreign keys, and bridge tables in database design. Expect a visual, diagram-based treatment showing how a many-to-many relationship is resolved with a bridge table whose key is typically the combination of the two foreign keys — the classic use case for a composite key.

Why this video

It supplies the design-level reasoning behind composite keys (when and why you need them) that pure syntax videos skip, and the bridge-table discussion directly supports the "referencing a composite key with foreign keys" subtopic.

Video 3: Composite key foreign key and primary key full explanation in Database@COMPUTEREXCELSOLUTION

COMPUTER & EXCEL SOLUTION · 7:44 · 842 views · 4y ago · captions — Watch on YouTube

About this video

A compact explanation that places composite keys alongside primary keys and foreign keys, defining each and showing how they relate within a database. It is positioned as a full-explanation overview, so expect definitions and simple examples rather than extended hands-on coding.

Why this video

It reinforces the vocabulary distinctions at the heart of this module by presenting composite, primary, and foreign keys together, which is useful review before or after the more technical demonstrations.

How These Videos Support the Learning Outcomes

Together these videos move from concept to code. The Lucid Software ERD tutorial and the COMPUTER & EXCEL SOLUTION overview help you distinguish composite keys from primary, foreign, and surrogate keys and judge when a multi-column natural key is the right design choice (MO1, MO3, MO4). The kudvenkat demonstration gives you the concrete SQL syntax for declaring a multi-column key constraint, which you will extend in practice to UNIQUE constraints and ALTER TABLE statements (MO2). The bridge-table material shows composite keys being referenced across related tables, providing the structural context in which you will later configure ON DELETE and ON UPDATE referential actions (MO5).

About These Videos

These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.