DROP TABLE sailors CASCADE;

CREATE TABLE sailors (
	sid		int,
	sname 	VARCHAR(20) NOT NULL,
	rating 	int,
	age 	float(10)
);


DROP TABLE boats CASCADE;

CREATE TABLE boats (
	bid		int NOT NULL,
	bname 	VARCHAR(20),
	color	VARCHAR(20)
);

DROP TABLE reserves CASCADE;

CREATE TABLE reserves (
	sid		int NOT NULL,
	bid		int NOT NULL,
	day		VARCHAR(20)
);

ALTER TABLE sailors ADD
 PRIMARY KEY (sid)
;

ALTER TABLE boats ADD
	PRIMARY KEY (bid)
;


ALTER TABLE reserves ADD
	FOREIGN KEY (sid) REFERENCES sailors(sid)
;
ALTER TABLE reserves ADD
	FOREIGN KEY (bid) REFERENCES boats(bid)
;



INSERT INTO sailors
		(	sid,	sname,		rating,		age )
VALUES (	22,		'Dustin',	7,			45 )
;
INSERT INTO sailors
		(	sid,	sname,		rating,		age )
VALUES (	29,		'Brutus',	1,			33 )
;
INSERT INTO sailors
		(	sid,	sname,		rating,		age )
VALUES (	31,		'Lubber',	8,			55.5 )
;
INSERT INTO sailors
		(	sid,	sname,		rating,		age )
VALUES (	32,		'Andy',		8,			25.5 )
;
INSERT INTO sailors
		(	sid,	sname,		rating,		age )
VALUES (	58,		'Rusty',	10,			35 )
;
INSERT INTO sailors
		(	sid,	sname,		rating,		age )
VALUES (	64,		'Horatio',	9,			35 )
;
INSERT INTO sailors
		(	sid,	sname,		rating,		age )
VALUES (	71,		'Zorba',	10,			16 )
;
INSERT INTO sailors
		(	sid,	sname,		rating,		age )
VALUES (	74,		'Horatio',	9,			35 )
;
INSERT INTO sailors
		(	sid,	sname,		rating,		age )
VALUES (	85,		'Art',		3,			25.5 )
;
INSERT INTO sailors
		(	sid,	sname,		rating,		age )
VALUES (	95,		'Bob',		3,			65.3 )
;



INSERT INTO boats
		(	bid,	bname,			color )
VALUES	(	101,	'Interlake',	'blue' )
;
INSERT INTO boats
		(	bid,	bname,			color )
VALUES	(	102,	'Interlake',	'red' )
;
INSERT INTO boats
		(	bid,	bname,			color )
VALUES	(	103,	'Clipper',		'green' )
;
INSERT INTO boats
		(	bid,	bname,			color )
VALUES	(	104,	'Marine',		'red' )
;



INSERT INTO reserves
		( sid,		bid,		day )
VALUES	( 22,	101, '10/10/98' );


INSERT INTO reserves
		( sid,		bid,		day )
VALUES	( 22,	102, '10/10/98' );


INSERT INTO reserves
		( sid,		bid,		day )
VALUES	( 22,	103, '10/8/98' );


INSERT INTO reserves
		( sid,		bid,		day )
VALUES	( 22,	104, '10/7/98' );


INSERT INTO reserves
		( sid,		bid,		day )
VALUES	( 31,	102, '11/10/98' );


INSERT INTO reserves
		( sid,		bid,		day )
VALUES	( 31,	104, '11/12/98' );


INSERT INTO reserves
		( sid,		bid,		day )
VALUES	( 64,	101, '9/5/98' );


INSERT INTO reserves
		( sid,		bid,		day )
VALUES	( 64,	102, '9/8/98' );


INSERT INTO reserves
		( sid,		bid,		day )
VALUES	( 74,	103, '9/8/98' );


INSERT INTO reserves
		( sid,		bid,		day )
VALUES	( 31,	103, '9/8/98' );



