Reputation: 174
I am using xamp. I created a DB using SQL Yog, I opened my localhost/phpmyadmin/ then selected the newly created database. I wanted to make relations among tables, for instance there are two tables,USER and USERSTATS, I want to create relation depending on USER_ID, which exists in both table. I selected create relation option, selected reference key from USERS table, then click on STATS table and selected foreign key, i got a prompt "Create relation", I clicked OK. Now it was to supposed to be creating relation, but it's not, just a small blank popup window opens in firefox, with link localhost/phpmyadmin/pmd_general.php?db=MYDBNAME&server=1&token=d9d3ed2661d4cc1d0db47eca1ebee996
But it is not creating the relation.
Please assist me in resolving this issue
Upvotes: 0
Views: 867
Reputation: 610
you need to add an index to the field you want as foreign key. You can do it by going to the table and clicking "Index" or you can do it manually: "ALTER TABLE YourTable
ADD INDEX ( YourField
)"
Upvotes: 0
Reputation: 4798
mysql
doesn't support the foreign key
relations, though it accepts that keyword. That's probably the reason phpMyAdmin
doesn't allow this.
If you can use InnoDB
engine for your table, foreign keys are supported.
From an answer from stackoverflow for why-my-table-doesnt-support-foreign-keys
ALTER TABLE tableName ENGINE = InnoDB;
Upvotes: 0
Reputation: 678
Did you go through the complete phpmyadmin installation steps? You have to create the phpmyadmin specific tables. Without them you will not be able to see relations or create them.
http://docs.phpmyadmin.net/en/latest/setup.html#phpmyadmin-configuration-storage
Upvotes: 0
Reputation: 4921
Have you created your tables with InnoDB
? InnoDB
accepts creation of foreign keys
Upvotes: 2