use `akura`;

UPDATE `STUDENT` 
SET TRAVEL_ID2 = NULL , TRAVEL_ID3 = null 
WHERE TRAVEL_ID2 = 0 OR TRAVEL_ID3 = 0;

UPDATE `STUDENT` 
SET TRAVEL_ID2 = NULL , TRAVEL_ID3 = null
WHERE TRAVEL_ID2 not in (select TRAVEL_ID from METHOD_OF_TRAVEL ) OR TRAVEL_ID3 not in (select TRAVEL_ID from METHOD_OF_TRAVEL);

ALTER TABLE `STUDENT` 
ADD CONSTRAINT `fk_STUDENT_TRAVELID2` 
FOREIGN KEY (`TRAVEL_ID2` )  REFERENCES `METHOD_OF_TRAVEL` (`TRAVEL_ID` )  
ON DELETE RESTRICT  ON UPDATE CASCADE, 
ADD CONSTRAINT `fk_STUDENT_TRAVELID3` 
FOREIGN KEY (`TRAVEL_ID3` )  REFERENCES `METHOD_OF_TRAVEL` (`TRAVEL_ID` ) 
ON DELETE RESTRICT  ON UPDATE CASCADE ;
