Vous êtes sur la page 1sur 5

CREATE TABLE customers ( custID INTEGER NOT NULL, LastName CHAR(18) NOT NULL, FirstName CHAR(18) NOT NULL,

PRIMARY KEY (custID) ); CREATE TABLE currencies ( from_currency CHAR(30) NOT NULL, ExchRate REAL NOT NULL, to_currency CHAR(30) NOT NULL, PRIMARY KEY (from_currency), FOREIGN KEY (to_currency) REFERENCES currencies(from_currency) ); CREATE TABLE cities ( city CHAR(18) NOT NULL, country CHAR(18) NOT NULL, currency CHAR(4) NOT NULL, airtax decimal(6,2) NOT NULL, PRIMARY KEY (city, country), FOREIGN KEY (currency) REFERENCES currencies(from_currency) ); CREATE TABLE AirLines ( Name CHAR(18) NOT NULL, city CHAR(18) NOT NULL, country CHAR(18) NOT NULL, PRIMARY KEY (Name), FOREIGN KEY (city,country) REFERENCES cities(city,country) ); CREATE TABLE flights ( Fno INTEGER NOT NULL, airl_Name CHAR(18) NOT NULL, price_currency CHAR(4) NOT NULL, dest_country CHAR(18) NOT NULL, orig_country CHAR(18) NOT NULL, orig_city CHAR(18) NOT NULL, price DECIMAL(6,2) NOT NULL, SMallow CHAR(1) NOT NULL, BCavlb CHAR(1) NOT NULL,

FlightLength INTEGER NOT NULL, dest_city CHAR(18), PRIMARY KEY (Fno), FOREIGN KEY (airl_Name) REFERENCES AirLines(Name), FOREIGN KEY (price_currency) REFERENCES currencies(from_currency), FOREIGN KEY (dest_city,dest_country) REFERENCES cities(city,country), FOREIGN KEY (orig_city,orig_country) REFERENCES cities(city,country) ); CREATE TABLE bookings ( BkgNum INTEGER NOT NULL, custID INTEGER NOT NULL, book_country CHAR(18) NOT NULL, dtax_country CHAR(18) NOT NULL, atax_country CHAR(18) NOT NULL, atax_city CHAR(18) NOT NULL, Fno INTEGER NOT NULL, BkgDate DATE NOT NULL, Depart DATE NOT NULL, Arrival DATE NOT NULL, Class CHAR(3) NOT NULL, Status CHAR(3) NOT NULL, paid CHAR(1) NOT NULL, balance DECIMAL(6,2) NOT NULL, TLname CHAR(18) NOT NULL, TFname CHAR(18) NOT NULL, dtax_city CHAR(18) NOT NULL, book_city CHAR(18) NOT NULL, PRIMARY KEY (BkgNum), FOREIGN KEY (custID) REFERENCES customers, FOREIGN KEY (book_city,book_country) REFERENCES cities(city,country), FOREIGN KEY (dtax_city,dtax_country) REFERENCES cities(city,country), FOREIGN KEY (atax_city,atax_country) REFERENCES cities(city,country), FOREIGN KEY (Fno) REFERENCES flights ); CREATE TABLE Eaddrs ( Eaddr CHAR(18) NOT NULL,

PRIMARY KEY (Eaddr) ); CREATE TABLE has_3 custID Eaddr PRIMARY KEY FOREIGN KEY FOREIGN KEY ); ( INTEGER NOT NULL, CHAR(18) NOT NULL, (custID, Eaddr), (Eaddr) REFERENCES Eaddrs, (custID) REFERENCES customers

CREATE TABLE addrs ( country CHAR(8) NOT NULL, province CHAR(8) NOT NULL, city CHAR(18) NOT NULL, StrNo CHAR(6) NOT NULL, pcode CHAR(6) NOT NULL, PRIMARY KEY (country, province, city, StrNo) ); CREATE TABLE has_4 custID country province city StrNo PRIMARY KEY FOREIGN KEY REFERENCES addrs, FOREIGN KEY ); ( INTEGER NOT NULL, CHAR(8) NOT NULL, CHAR(8) NOT NULL, CHAR(18) NOT NULL, CHAR(6) NOT NULL, (custID,country,province,city,StrNo), (country,province,city,StrNo) (custID) REFERENCES customers

CREATE TABLE faxes ( CountryCode CHAR(4) NOT NULL, AreaCode CHAR(3) NOT NULL, Number CHAR(8) NOT NULL, PRIMARY KEY (CountryCode, AreaCode, Number) ); CREATE TABLE has_2 ( custID CountryCode AreaCode INTEGER NOT NULL, CHAR(4) NOT NULL, CHAR(3) NOT NULL,

Number CHAR(8) NOT NULL, PRIMARY KEY (custID,CountryCode,AreaCode,Number), FOREIGN KEY (CountryCode,AreaCode,Number) REFERENCES faxes, FOREIGN KEY (custID) REFERENCES customers ); CREATE TABLE phones ( CountryCode CHAR(4) NOT NULL, AreaCode CHAR(3) NOT NULL, Number CHAR(8) NOT NULL, PRIMARY KEY (CountryCode, AreaCode, Number) ); CREATE TABLE has_1 custID CountryCode AreaCode Number PRIMARY KEY Number), FOREIGN KEY REFERENCES phones, FOREIGN KEY ); LIST TABLES; TERMINATE; ( INTEGER NOT NULL, CHAR(4) NOT NULL, CHAR(3) NOT NULL, CHAR(8) NOT NULL, (custID, CountryCode, AreaCode, (CountryCode,AreaCode,Number) (custID) REFERENCES customers

Here is the script to delete all tables:


CONNECT TO DROP TABLE DROP TABLE DROP TABLE DROP TABLE DROP TABLE DB4EB3; customers; currencies; cities; AirLines; flights;

DROP TABLE bookings; DROP TABLE Eaddrs; DROP TABLE has_3; DROP TABLE addrs; DROP TABLE has_4; DROP TABLE faxes; DROP TABLE has_2; DROP TABLE phones; DROP TABLE has_1; LIST TABLES; TERMINATE;

Vous aimerez peut-être aussi