Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
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)
);

Partially completed script

Code Block
languagesql
CREATE DATABASE places_visited;

CREATE TABLE travellers
(
	traveller_id	int	primary key auto_increment,
	first_name    		varchar(40),
	last_name   		varchar(40)
);

INSERT into travellers
    (traveller_id, first_name, last_name)
values
	(1, "Sel", "RTR"),
	(2, "Ligia", "Who"),
	(3, "Ariana", "What");

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

insert into destinations
	(destination_id, traveller, country, location)
values
	(1, 2, "Brasil", "Buzios"),
    (2, 1, "South Africa", "Jo/Burgh"),
    (3, 1, "Nepal", ""),
    (4, 2, "Brasil", "Rio De Janeiro"),
    (5, 1, "South Africa", "Mpumalanga"),
    (6, 1, "Jamaica", "Flogaman");