Primary keys - the basics
Single-column primary keys
Multicolumn primary keys
14. Uniqueness with multicolumn primary keys
Auto-increment columns and sequences
Revision

Instruction

Great, as you can see, we have successfully created the table. Now take a look at the contents of the table and study it closely.

There are two movies with the same title now - "The Kid". In our previous table, this would have been forbidden because the column title was the primary key and the values for the column title would have been considered as duplicated. Now, it is possible - one movie comes from the twenties, the other was produced in 2000. Together, these two values are unique for each of the two movies.

Exercise

Let's say we want to direct another movie under the title The Kid in 2016. The genre will be drama. Put that information into the table movie.

Stuck? Here's a hint!

Type

INSERT INTO movie VALUES ('The Kid', 2016, 'drama');

Console

Code editor

Result

TableConsole