Instruction
Very well done! How about multi-column primary keys? How can we define them? The syntax is a bit different:
CREATE TABLE tennis_racket ( manufacturer varchar(32), model varchar(32), rating integer, PRIMARY KEY (manufacturer, model) );
Now instead of adding PRIMARY KEY after a column type, we added the phrase PRIMARY KEY (manufacturer, model) after the last column definition. Inside the parentheses, we provide the names of the previously-defined columns that constitute the primary key.
An example from the previous exercise would look like this:
CREATE TABLE employee ( id integer, first_name varchar(32), last_name varchar(32), department varchar(32), PRIMARY KEY (id, department) );
Exercise
The company now needs a table to keep track of its departments. Create a table named department with the following columns:
country– Up to 32 characters.name– Up to 32 characters.address– Up to 64 characters.
The columns country and name should form the primary key.
Stuck? Here's a hint!
Use:
PRIMARY KEY (country, name)



