[2] | 1 | --name: Rick van der Zwet
|
---|
| 2 | --sid: 0433373
|
---|
| 3 | --file: ex2.sql
|
---|
| 4 | --vak/opdracht: Databases/ opdracht 2
|
---|
| 5 |
|
---|
| 6 | DROP TABLE Sleep;
|
---|
| 7 | DROP TABLE Coaches;
|
---|
| 8 | DROP TABLE Coach;
|
---|
| 9 | DROP TABLE Sportsman;
|
---|
| 10 |
|
---|
| 11 | CREATE TABLE Sportsman(
|
---|
| 12 | Sid integer NOT NULL,
|
---|
| 13 | Sname char(20),
|
---|
| 14 | Sage integer,
|
---|
| 15 | Scountry char(20),
|
---|
| 16 | PRIMARY KEY( Sid )
|
---|
| 17 | );
|
---|
| 18 |
|
---|
| 19 | CREATE TABLE Coach(
|
---|
| 20 | Cid integer NOT NULL,
|
---|
| 21 | Cname char(20),
|
---|
| 22 | Cage integer,
|
---|
| 23 | Ccountry char(20),
|
---|
| 24 | PRIMARY KEY( Cid )
|
---|
| 25 | );
|
---|
| 26 |
|
---|
| 27 | CREATE TABLE Coaches(
|
---|
| 28 | Cid integer,
|
---|
| 29 | Sid integer,
|
---|
| 30 | FOREIGN KEY ( Cid ) REFERENCES Coach( Cid ),
|
---|
| 31 | FOREIGN KEY ( Sid ) REFERENCES SportsMan( Sid )
|
---|
| 32 | );
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | CREATE TABLE Sleep(
|
---|
| 36 | Sid integer,
|
---|
| 37 | Branch char(20),
|
---|
| 38 | Day date,
|
---|
| 39 | NumHours integer,
|
---|
| 40 | PRIMARY KEY ( Sid, Day ),
|
---|
| 41 | FOREIGN KEY ( Sid ) REFERENCES SportsMan( Sid )
|
---|
| 42 | );
|
---|
| 43 |
|
---|
| 44 | INSERT INTO Sportsman VALUES ( 1, 'Rick', 15, 'nl' );
|
---|
| 45 | INSERT INTO Sportsman VALUES ( 2, 'Simoneer', 25, 'nl' );
|
---|
| 46 | INSERT INTO Sportsman VALUES ( 3, 'Simone', 38, 'nl' );
|
---|
| 47 | INSERT INTO Sportsman VALUES ( 4, 'Stefan', 20, 'de' );
|
---|
| 48 | INSERT INTO Sportsman VALUES ( 5, 'Anton', 25, 'de' );
|
---|
| 49 | INSERT INTO Sportsman VALUES ( 6, 'Henrich', 38, 'de' );
|
---|
| 50 | INSERT INTO Sportsman VALUES ( 7, 'Huibert', 18, 'fr' );
|
---|
| 51 | INSERT INTO Sportsman VALUES ( 8, 'Francios', 20, 'fr' );
|
---|
| 52 | INSERT INTO Sportsman VALUES ( 9, 'Nancy', 30, 'fr' );
|
---|
| 53 | INSERT INTO Sportsman VALUES ( 10, 'Rosa', 38, 'fr' );
|
---|
| 54 |
|
---|
| 55 | INSERT INTO Coach VALUES (1, 'coach 1', 10, 'nl' );
|
---|
| 56 | INSERT INTO Coach VALUES (2, 'coach 2', 20, 'nl' );
|
---|
| 57 | INSERT INTO Coach VALUES (3, 'coach 3', 30, 'de' );
|
---|
| 58 | INSERT INTO Coach VALUES (4, 'coach 4', 40, 'de' );
|
---|
| 59 | INSERT INTO Coach VALUES (5, 'coach 5', 50, 'de' );
|
---|
| 60 | INSERT INTO Coach VALUES (6, 'coach 6', 60, 'fr' );
|
---|
| 61 | INSERT INTO Coach VALUES (7, 'coach 7', 70, 'fr' );
|
---|
| 62 | INSERT INTO Coach VALUES (8, 'coach 8', 80, 'fr' );
|
---|
| 63 |
|
---|
| 64 | INSERT INTO Coaches VALUES ( 1, 1 );
|
---|
| 65 | INSERT INTO Coaches VALUES ( 2, 2 );
|
---|
| 66 | INSERT INTO Coaches VALUES ( 2, 5 );
|
---|
| 67 | INSERT INTO Coaches VALUES ( 3, 3 );
|
---|
| 68 | INSERT INTO Coaches VALUES ( 3, 2 );
|
---|
| 69 | INSERT INTO Coaches VALUES ( 4, 4 );
|
---|
| 70 | INSERT INTO Coaches VALUES ( 5, 5 );
|
---|
| 71 | INSERT INTO Coaches VALUES ( 6, 6 );
|
---|
| 72 | INSERT INTO Coaches VALUES ( 7, 7 );
|
---|
| 73 | INSERT INTO Coaches VALUES ( 8, 8 );
|
---|
| 74 |
|
---|
| 75 | INSERT INTO Sleep VALUES ( 1, 'judo', SYSDATE, 5 );
|
---|
| 76 | INSERT INTO Sleep VALUES ( 1, 'judo', SYSDATE+1, 9 );
|
---|
| 77 | INSERT INTO Sleep VALUES ( 1, 'judo', SYSDATE+2, 3 );
|
---|
| 78 | INSERT INTO Sleep VALUES ( 2, 'judo', SYSDATE, 3 );
|
---|
| 79 | INSERT INTO Sleep VALUES ( 3, 'judo', SYSDATE, 8 );
|
---|
| 80 | INSERT INTO Sleep VALUES ( 4, 'zwemmen', SYSDATE, 6 );
|
---|
| 81 |
|
---|