DBDIAGRAM.IO Three Things That Were Missing from Practice 1 Composite Primary Key The Indexes block marked as pk. A pair of columns defines a row. Composite uniqueness A separate ID has been entered; the uniqueness of the pair must be declared separately, otherwise the player will be entered into the match twice. CHECK is present, Note is not CHECK `check:` and `checks { }` define a CHECK; `Note` merely provides an explanation. `ref` references require `matches` and `players` to be declared. // A or B: alternatives; do not insert them together Table match_participants { match_id bigint [not null, ref: > matches.match_id] player_id bigint [not null, ref: > players.player_id] team smallint [not null, check: `team in (1,2)`] kills int [not null, default: 0, check: `kills >= 0`] Indexes { (match_id, player_id) [pk] } Note: 'One player — no more than one record per match' } // B: instead of A (only keys and references are shown) Table match_participants { participation_id bigint [pk, increment] match_id bigint [not null, ref: > matches.match_id] player_id bigint [not null, ref: > players.player_id] Indexes { (match_id, player_id) [unique] } }