Home » SQL & PL/SQL » SQL & PL/SQL » Help pls ...Unique constraint and Foreign Key
Help pls ...Unique constraint and Foreign Key [message #37479] Mon, 11 February 2002 10:16 Go to next message
laj
Messages: 2
Registered: February 2002
Junior Member
I quite new to SQLPLus, I've tried to read other question about this that is quite similar, but somehow I cant solve my problem...the error msg is ORA-00291- integrity constraint violated - parent key not found.
(I already key in all my parent column). Here is my table ..

CREATE TABLE Flight
(airlineName varchar(20) not null,
flightNo varchar(20) not null unique,
origin varchar(40) not null,
dest varchar(40) not null,
departDate date,
arrivalDate date,
departTime char(20),
duration char(20),
Primary Key (flightNo,departDate));

Create Table Price
(priceId char(5) not null unique,
tripType char(5),
fareType char(5),
price number(10),
Primary Key (priceId));

CREATE TABLE Customer
(custId varchar(20) not null unique,
PIN varchar(20) not null,
lastName char(25),
firstName char(25),
emailAdd char(20),
contact number(10),
creditCardNo number(25),
Primary key (custId));

Create Table Booking
(
bookingId number(5) not null unique,
custId varchar(20) not null,
departFlightNo varchar(20) not null,
returnFlightNo varchar(20),
priceId char(2) not null,
dateOfPurchase date,
departDate date,
returnDate date,
FOREIGN KEY(departFlightNo,departDate) REFERENCES Flight
FOREIGN KEY(returnFlightNo,departDate) REFERENCES Flight
FOREIGN KEY(custId) REFERENCES Csutomer
FOREIGN KEY(PriceId) REFERENCES Price
);

I know the problem is with my BOOKING table, especially in the Foreign key and Unique constratin in the other table (i need them to be unique)..

Problem when I key in Booking row,
insert into Booking values ('1','c1','AA213','AA214','Q','21-DEC-01','03-JAN-02','10-JAN-02');
Anybody ?? ... thx in advance =)
Re: Help pls ...Unique constraint and Foreign Key [message #37481 is a reply to message #37479] Mon, 11 February 2002 10:42 Go to previous messageGo to next message
laj
Messages: 2
Registered: February 2002
Junior Member
oh ya sorry for the mistyped in Booking Table...is not Csutomer but Customer

=)
Re: Help pls ...Unique constraint and Foreign Key [message #37499 is a reply to message #37479] Tue, 12 February 2002 02:50 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
Hi,

when u say primary key , then automatically it is unique.

before inserting into booking table make sure u have entered parent records.

cheers
pratap
Previous Topic: after coding the sucessful cursor what are the steps to get the cursor output
Next Topic: explain plan
Goto Forum:
  


Current Time: Fri Apr 19 17:56:39 CDT 2024