Jump to content

relationship between table


nec9716

Recommended Posts

I want to create relation between table but I have an issue.

 

not sure if I write the line properly?

 

alter table `matnphil_f1`.`pick` add constraint `FK_pick` FOREIGN KEY (`id`) REFERENCES `user` (`userid`)

 

do the table need to be emty to do that?

presently I have data in all table .....

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/100322-relationship-between-table/
Share on other sites

There are different types of constraints and relationships, but I am not sure I understand why you would want to use a non-pk in one table as a fk in another? A relationship can be between anything; but it just makes sense to use the primary key.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.