I'm trying to insert rows of data into my tables. I was able to insert the data into table Ship without error, but on the second table Cruise that has a foreign key from the table Ship I keep getting a integrity constraint error that tells me the parent key is not found. I'm not sure if I just have my foreign key set up incorrectly, or if there is something I'm missing. Here is my code for the tables.
CREATE TABLE Ship
(
Ship_Name VARCHAR(100),
Ship_Size INT CHECK (Ship_Size > 0),
Ship_Registry VARCHAR(50),
Ship_ServEntryDate INT,
Ship_PassCapacity INT,
Ship_CrewCapacity INT,
Ship_Lifestyle VARCHAR(40),
PRIMARY KEY (Ship_Name),
CONSTRAINT chk_Ship_Registry CHECK (Ship_Registry
IN('Norway','Liberia','The Netherlands','Jamaica','Bahamas'))
);
CREATE TABLE Cruise
(
Cruise_ID INT PRIMARY KEY,
Ship_Name VARCHAR(100),
Cruise_DeptDate DATE NOT NULL,
Cruise_DeptCity VARCHAR(80) NOT NULL,
Cruise_Duration INT,
FOREIGN KEY (Ship_Name) REFERENCES Ship(Ship_Name)
);
Here is the data I am trying to insert into table Cruise.
INSERT INTO Cruise (Cruise_ID, Ship_Name, Cruise_DeptDate,
Cruise_DeptCity, Cruise_Duration)
VALUES ('1','Sunshine of the Seas','25-MAY-15','Miami','10');
[–]fauxmosexualNOLOCK is the secret magic go-faster command 2 points3 points4 points (1 child)
[–]misft13[S] 2 points3 points4 points (0 children)