posted 8 years ago
I have to add two foregn keys from two different table into on single but it showing error that "Cannot add foreign Key Constraint".....Please help me
FIRST TABLE
CREATE TABLE Train_Details
(
Train_ID int PRIMARY KEY not null,
Train_Name varchar(60) not null,
Train_Type varchar(25) not null
);
SECOND TABLE
CREATE TABLE Passenger_Details
(
Passenger_ID int unsigned auto_increment primary key,
Full_Name varchar(25) not null,
Address varchar(100) not null,
Age int unsigned not null,
Gender varchar(10) not null,
DOB date not null,
Phone long not null,
Train_ID int,
Foreign key (Train_ID) references Train_Details(Train_ID)
);
THIRD TABLE
CREATE TABLE Booking_Passenger_Details
(
Serial_No int unsigned auto_increment primary key,
Train_ID int unsigned not null,
Passenger_ID int unsigned not null,
Seat_No int unsigned not null,
Class varchar(25) not null,
FOREIGN KEY (Passenger_ID) REFERENCES Passenger_Details(Passenger_ID),
FOREIGN KEY (Train_ID) REFERENCES Train_Details(Train_ID)
)Engine=InnoDB;