Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE category (
- id NUMBER NOT NULL CONSTRAINT pk_category PRIMARY KEY,
- genre VARCHAR2(100)
- )
- INSERT INTO category VALUES (1, 'Aeronáutica [AVIAÇÃO]');
- INSERT INTO category VALUES (2, 'Aviação Civil');
- INSERT INTO category VALUES (3, 'Aviação Comercial');
- INSERT INTO category VALUES (4, 'Aviação Militar');
- INSERT INTO category VALUES (5, 'Aviação Geral');
- INSERT INTO category VALUES (6, 'Linhas Aéreas');
- SELECT * FROM category; -- ok
- CREATE TABLE pilot(
- brevet NUMBER NOT NULL PRIMARY KEY,
- fname VARCHAR(50) NOT NULL,
- lname VARCHAR(150),
- entry DATE DEFAULT SYSDATE NOT NULL,
- pilotcategory NUMBER NOT NULL,
- CONSTRAINT fk_pilotcat FOREIGN KEY (pilotcategory) REFERENCES category(id)
- );
- INSERT INTO pilot VALUES (1, 'Márcio', 'Santos', '10-02-2001', 1);
- INSERT INTO pilot VALUES (2, 'Marcelo', 'Alves', '12-05-2004', 2);
- INSERT INTO pilot VALUES (3, 'Mariana', 'Juana', '12-08-2005', 2);
- INSERT INTO pilot VALUES (4, 'Karine', 'Gomes', '20-12-2002', 3);
- INSERT INTO pilot VALUES (5, 'Rodrigo', 'Lins', '25-10-2001', 1);
- INSERT INTO pilot VALUES (6, 'João', 'Augusto', '18-06-2000', 4);
- SELECT * FROM pilot; -- ok
- CREATE TABLE airplanecategory (
- id NUMBER NOT NULL PRIMARY KEY,
- genre VARCHAR2(100)
- )
- INSERT INTO airplanecategory VALUES (1, 'Civil');
- INSERT INTO airplanecategory VALUES (2, 'Militar');
- INSERT INTO airplanecategory VALUES (3, 'Experimental');
- INSERT INTO airplanecategory VALUES (4, 'Hidro');
- INSERT INTO airplanecategory VALUES (5, 'Supersônico');
- SELECT * FROM airplanecategory; -- ok
- CREATE TABLE airplane (
- id NUMBER NOT NULL PRIMARY KEY,
- category NUMBER NOT NULL,
- capacity NUMBER NOT NULL,
- CONSTRAINT fk_airplane FOREIGN KEY(category) REFERENCES airplanecategory(id)
- );
- INSERT INTO airplane VALUES (1, 1, 500);
- INSERT INTO airplane VALUES (2, 2, 1);
- INSERT INTO airplane VALUES (3, 2, 20);
- INSERT INTO airplane VALUES (4, 1, 200);
- INSERT INTO airplane VALUES (5, 4, 4);
- INSERT INTO airplane VALUES (6, 1, 650);
- SELECT * FROM airplane; -- ok
- CREATE TABLE travel(
- brevet NUMBER NOT NULL,
- plane NUMBER NOT NULL,
- tdate DATE DEFAULT SYSDATE NOT NULL,
- location VARCHAR2(100),
- CONSTRAINT fk_travel_brevet FOREIGN KEY (brevet) REFERENCES pilot(brevet),
- CONSTRAINT fk_travel_plane FOREIGN KEY (plane) REFERENCES airplane(id)
- );
- INSERT INTO travel VALUES (1, 1, '10-10-2010', 'Brasil');
- INSERT INTO travel VALUES (2, 3, '10-11-2008', 'Holanda');
- INSERT INTO travel VALUES (2, 3, '12-02-2011', 'México');
- INSERT INTO travel VALUES (4, 2, '20-01-2005', 'Argentina');
- INSERT INTO travel VALUES (1, 4, '11-06-2000', 'Estados Unidos');
- INSERT INTO travel VALUES (3, 1, '19-10-2011', 'Argentina');
- SELECT * FROM travel; -- ok
- -- :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement