I want to make namecon of table "paper" as a foreign key reference to table "journal" to its primary key jname. I am getting confused with this view and not finding any tutorial or link which is explaining to set foreign key with this schema of phpMyAdmin. (Is it new or what) Please someone let me to figure this out.
Setting foreign key in phpMyAdmin
1.2k views Asked by hawkeye At
2
There are 2 answers
0
On
First, you need to create an index on the namecon
column, click on the Structure tab ("Table structure" sub-heading on newer phpMyAdmin versions), then the Index
text for the namecon column. You also need an index on the jname
column in your journal
table; in most of my databases this is an auto incrementing primary key but all that MySQL requires is that it's an index.
Next, go back to the Relation View (which is a sub-heading of Structure under newer versions). Note that this is in the area for "Foreign key constraints" not "Internal relations." Now you'll be able to select namecon from the "Column" dropdown:
If you want you can give it a name, otherwise MySQL generates one for you.
While making the foreign key, it is also advisable to mark the index key option available int Structure view of the table. That will make the primary key thing to visible in the relational view of that particular table which can be used for making foreign key.