xxreenaxx1 Posted January 22, 2011 Share Posted January 22, 2011 Hi, for eg: Foreign key(staffid) references user(userid) Foreign ket(studentid) references user(userid) Can you have this statement in one table. Quote Link to comment https://forums.phpfreaks.com/topic/225293-can-a-foreign-key-be-used-twice-in-a-table/ Share on other sites More sharing options...
codefossa Posted January 22, 2011 Share Posted January 22, 2011 I'm not 100% sure of what you're asking, but here's what I believe you are asking. You basically want to have two types of ID's in a single table. (Students & Staff) To do this, I would just add an extra column which would be named 'type' or 'staff', whatever you want. Then make sure it's an int, and just use 0 & 1 to represent student or staff. If it's not what you wanted, then sorry. Quote Link to comment https://forums.phpfreaks.com/topic/225293-can-a-foreign-key-be-used-twice-in-a-table/#findComment-1163509 Share on other sites More sharing options...
fenway Posted January 26, 2011 Share Posted January 26, 2011 Hi, for eg: Foreign key(staffid) references user(userid) Foreign ket(studentid) references user(userid) Can you have this statement in one table. Did you try? Quote Link to comment https://forums.phpfreaks.com/topic/225293-can-a-foreign-key-be-used-twice-in-a-table/#findComment-1165442 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.