Instruction
Boom! The insertion failed because we already have a row with the name 'Monopoly'. Our new constraint takes care of that.
UNIQUE is indeed very similar to PRIMARY KEY which we learned in the previous part. We sometimes say that UNIQUE creates an alternate key.
Exercise
It's time for you to create your own table board_game with the UNIQUE column. Let us remind you about the columns we have:
idwhich is anIDENTITYand the primary key,nameis a text of up to 32 characters (must be unique!),genrewhich is also a text of up to 32 characters,min_playersandmin_agewhich are integers,pricewhich is a decimal value of up to 5 digits, 2 of which are after the decimal point.
UNIQUE constraint is placed after the column type!
Stuck? Here's a hint!
Type
CREATE TABLE board_game (
id IDENTITY PRIMARY KEY,
name varchar(32) UNIQUE,
genre varchar(32),
min_players int,
min_age int,
price decimal(5, 2),
);


