Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 2 Next »

Create destinations table

CREATE TABLE destinations
(
	destinationI_id		int	primary key,
	country    			varchar(40),
	location   			varchar(40),
    traveller			int,
    foreign key (traveller) references travellers(traveller_id)
);

How to create a composite key

You will to define the column using this syntax, anything in bold is keyword, the other parts your field names

constraint visit_key primary key (destination, purpose, date_of_visit)

CREATE TABLE visits
(
	date_of_visit		date,
	destination    		int,
	purpose   			int,
    foreign key (destination) references destinations(destination_id),
    foreign key (purpose) references purpose(id),
    constraint visit_key primary key (destination, purpose, date_of_visit)
);

  • No labels