Jump to content

foreign key


jimfog

Recommended Posts

I Intend using a group of columns as a foreign key.I have a parent table named credentials(crID column is the primary key). CrID will go in a child table, in to 2 columns(as a foreign key). As far as I understand there seems not to have a problem with such a scheme. It has to do with a booking application. The columns that contain the crID are called bookedFrom and bookedFor...to get an understanding of the logic. What I do not understand is this phrase in the MySQl manual regarding multiple columns foreign keys: However, in the referenced table, there must be an index where the referenced columns are listed as the first columns in the same order. It is found here-just use the browser "find" function to find it:http://dev.mysql.com/doc/refman/5.7/en/create-table-foreign-keys.html

Link to comment
Share on other sites

That's talking about a foreign key being multiple distinct columns from one table. You're talking about multiple foreign keys that reference the same column, that's not the same thing. Both are fine to do, if you have a single foreign key that references multiple columns then the note means that the parent table must have an index that lists the columns that are foreign keys in the same order as the order in which the foreign key is defined.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...