mysql - Same foreign key in multiple tables -


I have seen posts through SO and Google that you can not get many foreign keys with the same name with MySQL My problem is that how do I refer to the same table in several other tables from one table? In my case I have a family table that includes FAM_ID. I want this to be a foreign key in my document and contact table, because the rows in it are related to FAM_ID, so if I think that what I have read is fine, then I must give the name of the column in the documents and FAMILI To map the FAM_ID as a foreign key in the table, contact different names (compared to FAM_ID) to map them. Do not I understand anything or is this my only option? It seems that this data model will have a fairly common requirement.

You do not need them to name them different things You have a FAM_ID column in FAMILY, FAM_ID in DOCUMENTS Columns and FAM_ID columns can be found in CONTACT.

In this case, giving them the same name makes it clear that they mention the same thing

For example, on the family table, I family_ID < I use something on the lines of / code>, and when referring to it from contact_family_id , document_familyID contact and document tables.

The only negative aspect of giving them names, as far as I can see, is that when you add, you can not see them with only the pillar name, you have to surname them or they The reference must be made by tablename.columnname.

Edit: I think what I found is that by means of not being able to name you the same name is a matter of when you add a foreign key relationship within a table , As described here:


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -