Welcome Guest, Not a member yet? Register   Sign In
How to put Foreign Key using PHPMyAdmin?
#1

[eluser]solid9[/eluser]
Hi guys

I know this is very basic.
I'm just wondering if it is possible to create a Foreign key
using PHPMyAdmin. Since I haven't tried this.

If the answer is yes can you guys guide me.

Thanks in advanced.
#2

[eluser]solid9[/eluser]
For example I will create a new table called "swap".
Now in swap table I want to include a Foreign key from "users" table.
How I do about this?, using PHPMyAdmin?

Thanks in advanced.




#3

[eluser]InsiteFX[/eluser]
See the MySQL Alter command

Code:
ALTER TABLE `topics` ADD FOREIGN KEY(`topic_cat`)  REFERENCES `categories` (`cat_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `topics` ADD FOREIGN KEY(`topic_by`)   REFERENCES `users` (`user_id`)     ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE `posts`  ADD FOREIGN KEY(`post_topic`) REFERENCES `topics` (`topic_id`)   ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `posts`  ADD FOREIGN KEY(`post_by`)    REFERENCES `users` (`user_id`)     ON DELETE RESTRICT ON UPDATE CASCADE;
#4

[eluser]solid9[/eluser]
@InsiteFX

I'll review the alter table command.

thanks




Theme © iAndrew 2016 - Forum software by © MyBB