Jump to content

creating a foreign key


jimfog

Recommended Posts

I use phpmyadmin to handle the db. I wrote a query to add a foreign key in an existing table, despite getting a success message that the query was completed, I cannot find an indication that a foreign key was indeed created. I mean, phpmyadmin seems not provide info saying for example "this column is the foreign key" as the case is when a column is the primary key. It does not say of course "this column is the primary key", but instead it highlights the word primary. I do not see an similar indication about foreign keys. The only thing maybe that gives the info i want is this "Relation view" option-I am not sure though.

Link to comment
Share on other sites

If you're looking at the table structure page, information about keys and indexes is given in the Indexes table below the column table.
yes, I know what are you talking about but it does not mention which is the foreign key.It does mention the keyname and the column but it DOES NOT mention anything about foreign key.
Link to comment
Share on other sites

Yes, this where I should be looking into.There is something though that has caught my attention. AS I said I have created a foreign key between two tables-in the one table, and in the relation view, indeed a relation is shown between a columnwith the column in the other table. IN the second table though, in the relation view again, and in the column from which values are taken(as the foreign key points here), no relation is seen, the specific drop down menu field is empty. Is this the way foreign keys work, going from a table column to another table column in one way only, NOT bidirectional i mean? Or do you think there is an error somewhere? Probably this is the case, no errors, father-child table relationship.

Edited by jimfog
Link to comment
Share on other sites

There's no relation stored in the parent table. If phpMyAdmin were to show a relationship there then it would need to look at all indexes from all other tables and see if any of them refer to the parent table. The relationship is only stored with the child table, that's where the index 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...