SHARE
TWEET

Untitled

a guest May 22nd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE airport(
  2.    id int NOT NULL,
  3.    name CHAR(50) NOT NULL,
  4.    location CHAR(50) NOT NULL,
  5.    numberOfPlane int NOT NULL,
  6.    CONSTRAINT airport_pk PRIMARY KEY (id)  
  7. );
  8.  
  9. DROP TABLE airport;
  10.  
  11.  
  12. /*-------------------------------*/
  13. CREATE TABLE airplane(
  14.   id int NOT NULL,
  15.   name CHAR(50) NOT NULL,
  16.   numberOfSeat int NOT NULL,
  17.   airport_id int,
  18.   CONSTRAINT airplane_pk PRIMARY KEY(id),
  19.   CONSTRAINT fk_airplane
  20.     FOREIGN KEY (airport_id)
  21.     REFERENCES airport (id)
  22. );
  23.  
  24. DROP TABLE airplane;
  25.  
  26.  
  27. /*-------------------------------*/
  28. CREATE TABLE passenger(
  29.   id int NOT NULL,
  30.   name CHAR(50) NOT NULL,
  31.   phone CHAR(50) NOT NULL,
  32.   mail CHAR(50) NOT NULL,
  33.   CONSTRAINT passenger_pk
  34.     PRIMARY KEY (id)
  35. );
  36.  
  37. DROP TABLE passenger;
  38.  
  39.  
  40. /*-------------------------------*/
  41. CREATE TABLE flight1(
  42.   flightid int NOT NULL,
  43.   passenger_id int NOT NULL,
  44.   airplane_id int NOT NULL,
  45.   departure_time DATE,
  46.   arrival_time DATE,
  47.   fromWhere CHAR(50),
  48.   toWhere CHAR(50),
  49.   PRIMARY KEY (flightid),
  50.   CONSTRAINT flight_fk1
  51.     FOREIGN KEY (airplane_id)
  52.     REFERENCES airplane1 (id),
  53.   CONSTRAINT flight_fk2
  54.     FOREIGN KEY (passenger_id)
  55.     REFERENCES passenger1 (id)
  56. );
  57.  
  58. DROP TABLE flight1;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top