tabel

Download Tabel

If you can't read please download the document

Upload: fadli

Post on 14-Sep-2015

12 views

Category:

Documents


4 download

DESCRIPTION

query tabel

TRANSCRIPT

CREATE TABLE Boat_types ( bt_id char(45)Primary key, bt_name varchar(45), )CREATE TABLE boats ( bid char(11)PRIMARY KEY, bname varchar(45), color varchar(45), boat_type char(45), CONSTRAINT Fk_Boat1 FOREIGN KEY(boat_type)REFERENCES Boat_types(bt_id))CREATE TABLE sailors ( sid char(11)PRIMARY KEY, sname varchar(45), rating char(11), age float, )CREATE TABLE reserves ( sid char(11), bid char(11), day date, CONSTRAINT PK_reserves PRIMARY KEY(sid,bid,day),CONSTRAINT FK_sid FOREIGN KEY(sid)REFERENCES sailors(sid),CONSTRAINT FK_reservers2 FOREIGN KEY(bid)REFERENCES boats(bid), )INSERT INTO Boat_types (bt_id,bt_name) VALUES ('T01','siliboat');INSERT INTO Boat_types (bt_id,bt_name) VALUES ('T02','motorboat');INSERT INTO Boat_types (bt_id,bt_name) VALUES ('T03','airboat');INSERT INTO boats (bid,bname,color,boat_type) VALUES (101,'Interlake','blue','T01');INSERT INTO boats (bid,bname,color,boat_type) VALUES (102,'Interlake','red','T01');INSERT INTO boats (bid,bname,color,boat_type) VALUES (103,'Clipper','green','T02');INSERT INTO boats (bid,bname,color,boat_type) VALUES (104,'Marine','red',null);INSERT INTO sailors (sid,sname,rating,age) VALUES (22,'Dustin',7,45.0);INSERT INTO sailors (sid,sname,rating,age) VALUES (29,'Brutus',1,33.0);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.0);INSERT INTO sailors (sid,sname,rating,age) VALUES (64,'Horatio',7,35.0);INSERT INTO sailors (sid,sname,rating,age) VALUES (71,'Zorba',10,16.0);INSERT INTO sailors (sid,sname,rating,age) VALUES (74,'Horatio',9,35.0);INSERT INTO sailors (sid,sname,rating,age) VALUES (85,'Art',3,25.5);INSERT INTO sailors (sid,sname,rating,age) VALUES (95,'Bob',3,63.5);INSERT INTO reserves (sid,bid,day) VALUES (22,101,'1998-10-10');INSERT INTO reserves (sid,bid,day) VALUES (22,102,'1998-10-10');INSERT INTO reserves (sid,bid,day) VALUES (22,103,'1998-10-8');INSERT INTO reserves (sid,bid,day) VALUES (22,104,'1998-10-7');INSERT INTO reserves (sid,bid,day) VALUES (31,102,'1998-11-10');INSERT INTO reserves (sid,bid,day) VALUES (31,103,'1998-11-6');INSERT INTO reserves (sid,bid,day) VALUES (31,104,'1998-11-12');INSERT INTO reserves (sid,bid,day) VALUES (64,101,'1998-9-5');INSERT INTO reserves (sid,bid,day) VALUES (64,102,'1998-9-8');INSERT INTO reserves (sid,bid,day) VALUES (74,103,'1998-9-8');