Q: I am running into a repeated problem with a parent key not found I'm able to insert the customer information but, then I try to insert Reservation information and then I get the error : ORA-02291: integrity constraint violated - parent key not found.
I guess my question is do I need to put data in there a order of which table need to have data first? Or is there something else I'm missing?
I am still fairly new to SQL this being my first SQl class and any help will be appreciated.
Also I will have some parts of the data the same so I want to also know how I can have duplicates in a table.
CREATE TABLE City
(City_Code VARCHAR2(3) CONSTRAINT pk_City Primary Key,
City_Name VARCHAR2(15),
State_ VARCHAR2(2)
);


CREATE TABLE Airport
(Airport_Code VARCHAR2(7) CONSTRAINT pk_Airport Primary Key,
City_Code VARCHAR2(3), CONSTRAINT fk_Airport_City_Code FOREIGN KEY(City_Code)
REFERENCES City, 
Airport_Name VARCHAR2(30)
);


CREATE TABLE Acraft_Data
(Type_ VARCHAR2(6),
Description_ VARCHAR2(20),
Capacity_ VARCHAR2(3),
Range_ VARCHAR2(4)
);

CREATE TABLE AirCraft_Type
(Serial_Num VARCHAR2(8) CONSTRAINT pk_AirCraft_Type Primary Key, 
Type_ VARCHAR2(6), CONSTRAINT fk_AirCraft_Type FOREIGN KEY(Type_)
REFERENCES ACraft_Data
);


CREATE TABLE FlightData
(Flt_Nbr VARCHAR2(3) CONSTRAINT pk_FlightData Primary Key,
Depart_Code VARCHAR2(30),
CONSTRAINT fk_Flight_Data_Depart_Code FOREIGN KEY(Depart_Code)
REFERENCES Airport,
Ariv_Code VARCHAR2(30),
CONSTRAINT fk_Flight_Data_Ariv_Code FOREIGN KEY(Ariv_Code)
REFERENCES Airport
);

CREATE TABLE Shed_Flight(
  Flt_Date DATE
              NOT NULL,
  Flt_Nbr  VARCHAR2(3)
              NOT NULL,    
  Seats_Resvd VARCHAR2(3),
  Seat_Ava   VARCHAR2(3),
  TOD         VARCHAR2(8),
  TOA         VARCHAR2(8),
  Serial_Num     VARCHAR2(10),
  CONSTRAINT PK_Shed_Flight PRIMARY KEY(Flt_Nbr, Flt_Date),
    CONSTRAINT fk_Shed_Flight_Flight_Nbr
    FOREIGN KEY (Flt_Nbr) REFERENCES FlightData (Flt_Nbr),
  CONSTRAINT fk_Shed_Flight
    FOREIGN KEY (Serial_Num) REFERENCES AirCraft_Type (Serial_Num)
);

CREATE TABLE CustomerAP
(Cust_Nbr VARCHAR2(4) CONSTRAINT pk_Customer Primary Key NOT NULL,
Cust_Name VARCHAR2(15) NOT NULL
);


CREATE TABLE Reservation(
Cust_Nbr    VARCHAR2(4)
              NOT NULL,
  Flt_Nbr  VARCHAR2(3)
              NOT NULL,
  Flt_Date DATE
              NOT NULL,
  CONSTRAINT fk_Reservation_Cust_Nbr
    FOREIGN KEY (Cust_Nbr) REFERENCES CustomerAP (Cust_Nbr),
  CONSTRAINT fk_Flt_Nbr_Flt_Date
    FOREIGN KEY (Flt_Nbr, Flt_Date) REFERENCES Shed_Flight ( Flt_Nbr, Flt_Date )

);


Reservation insert

INSERT INTO Reservation values(1001, 181, '07/13/2000');
INSERT INTO Reservation values(1004, 110, '07/12/2000');
INSERT INTO Reservation values(1004, 899, '07/14/2000');
INSERT INTO Reservation values(1055, 359, '07/13/2000');
INSERT INTO Reservation values(1058, 950, '07/13/2000');
INSERT INTO Reservation values(1058, 899, '07/14/2000');
INSERT INTO Reservation values(1077, 110, '07/12/2000');
INSERT INTO Reservation values(1080, 333, '07/13/2000');
INSERT INTO Reservation values(1100, 359, '07/132000');
INSERT INTO Reservation values(1155, 359, '07/13/2000');
INSERT INTO Reservation values(1158, 110, '07/12/2000');
INSERT INTO Reservation values(1158, 899, '07/13/2000');


Customer Insert

INSERT INTO CustomerAP values(1001, 'Ford');
INSERT INTO CustomerAP values(1004, 'Pfeiffer');
INSERT INTO CustomerAP values(1055, 'Harris');
INSERT INTO CustomerAP values(1058, 'Codd');
INSERT INTO CustomerAP values(1077, 'Nelson');  
INSERT INTO CustomerAP values(1080, 'Cassatt');
INSERT INTO CustomerAP values(1100, 'Streep');
INSERT INTO CustomerAP values(1155, 'Lechowick');


ACraft_Data

INSERT INTO ACraft_Data values( 'BO727','5-Seat, 2-engine jet', 110, 1800);
INSERT INTO ACraft_Data values( 'DC9', '6-Seat, prop w/jet', 168, 2800);
INSERT INTO ACraft_Data values( 'BO737', '6-Seat, 2-engine jet', 174, 2500);
INSERT INTO ACraft_Data values( 'BO747', '10-Seat, 4-engine jet', 300, 3500);
INSERT INTO ACraft_Data values( 'DC9', '6-Seat, prop w/jet', 168, 2800);
INSERT INTO ACraft_Data values( 'BO737', '6-Seat, 2-engine jet', 174, 2500);
INSERT INTO ACraft_Data values( 'BO727', '5-Seat, 2-engine jet', 110, 1800);


A: CONSTRAINT fk_Reservation_Cust_Nbr
    FOREIGN KEY (Cust_Nbr) REFERENCES CustomerAP (Cust_Nbr)

when you set a FK that reference to another table column then you can't insert something not in the ref col.
INSERT INTO Reservation values(1158, 110, '07/12/2000');
INSERT INTO Reservation values(1158, 899, '07/13/2000');

those two rows with Cust_Nbr : 1158 data violate this rule. either add this data in ref table or don't add those data and you should be fine.But make sure you check if there is any other similar mistake.
check MSDN for better info.

A: INSERT INTO tables in the following order, some tables are depended on other tables for primary keys.
City, 
Acraft_Data, 
Airport, 
AirCraft_Type, 
FlightData ,
Shed_Flight, 
CustomerAP, 
Reservation

