i tried to add foreign key but cudn't add it. i read several questions regarding this matter. but those options are not works with me. ( Tried as this way too
My table structure as below
tab_project
column Name
ProjectID -- > primary key
ProjectName
tab_project_day
Primary Key ----> ProjectID + Day
foreign key ----> ProjectID references ProjectID in tab_project
tab_photo
Primary Key ---->
i want to create tab_photo foreign keys as follows:
tab_photo.ProjectID --- > reference tab_project_day.ProjectID
tab_photo.Day ------- > reference tab_project_day.day
in here it does not allow me to add tab_photo.Day key.
i tried this one--
ALTER TABLE `tab_photo` ADD FOREIGN KEY (`Day`) REFERENCES
`xyz`.`tab_project_day`(`Day`) ON DELETE RESTRICT ON UPDATE RESTRICT;
it gives below error :
#1005 - Can't create table 'xyz.#sql-97c_1c6' (errno: 150)
what is the reason for this? please help!!!