Learn VisualLearn DB

Reject Duplicate Identifiers

A primary key uniquely identifies every row and cannot be NULL. UNIQUE protects another candidate key without replacing the primary identifier. For example, UNIQUE (order_id, line_no) allows the same line_no to repeat across orders, but not within one order.

GOAL

Choose between PRIMARY KEY, UNIQUE, and a multicolumn UNIQUE constraint.

Two orders may both have line_no 1, but one order cannot contain line_no 1 twice. Which constraint fits?