phpfan Posted February 28, 2007 Share Posted February 28, 2007 Hi, Please help me, i have a very straight forward question but it seems that i cannot find any answer.... I am new in the area so please explain to me as simple as you can... How i can create foreign keys using phpMyAdmin? I am currently developing a dynamic website using php and phpMyAdmin but i cannot find out how i can create foreign keys.. For example i have two tables (PRODCUTS and PRODUCTDETAILS) how i can reference the primary key of table PRODUCTS which is product_id as a foreign key in table PRODUCTDETAILS ? Thank you in advance Quote Link to comment https://forums.phpfreaks.com/topic/40436-phpmyadmin-foreign-keys/ Share on other sites More sharing options...
designationlocutus Posted February 28, 2007 Share Posted February 28, 2007 Define your product_id as an unsigned int. Im not too sure if there's a foreign key type, but the joins will work fine within the SQL. Quote Link to comment https://forums.phpfreaks.com/topic/40436-phpmyadmin-foreign-keys/#findComment-195662 Share on other sites More sharing options...
phpfan Posted February 28, 2007 Author Share Posted February 28, 2007 I need to do this with the right way because the website that i am developing is a part of an assignment... :-\ Quote Link to comment https://forums.phpfreaks.com/topic/40436-phpmyadmin-foreign-keys/#findComment-195670 Share on other sites More sharing options...
artacus Posted February 28, 2007 Share Posted February 28, 2007 Then you'll need to use innoDB tables because myISAM does not support fk relationships. I'm not really sure what you mean by "reference." You can join them in a query w/o having fk's defined. phpMyAdmin also stores relationship information in a separate database if you have that set up right. But like I said, I'm not really sure what you are asking. Quote Link to comment https://forums.phpfreaks.com/topic/40436-phpmyadmin-foreign-keys/#findComment-195682 Share on other sites More sharing options...
designationlocutus Posted February 28, 2007 Share Posted February 28, 2007 I need to do this with the right way because the website that i am developing is a part of an assignment... :-\ Nice Well I'd suggest you explore further. Try mysql.com to see if there's a foreign key type included If not document it in your schema for your assignment that it is a foreign key type. Im sure your tutors will be impressed that you investigated it. Good luck with your assignment. Quote Link to comment https://forums.phpfreaks.com/topic/40436-phpmyadmin-foreign-keys/#findComment-195693 Share on other sites More sharing options...
phpfan Posted February 28, 2007 Author Share Posted February 28, 2007 Thank you guys, i will try to enable innoDB because is currently disable and try to work it out, but probably i will be back for more guidance Quote Link to comment https://forums.phpfreaks.com/topic/40436-phpmyadmin-foreign-keys/#findComment-195718 Share on other sites More sharing options...
phpfan Posted February 28, 2007 Author Share Posted February 28, 2007 Hi i am back..... I manage to activate InnoDB and know i can use them, but i still did not understand how i can create foreign keys using phpMyAdmin.. I am confused... Can anybody please just use five minutes of his time to explain me or point me were to look for.. I have a table called PRODUCTS having as primary key the PRODUCTID and also some other fields like PRODUCTNAME, PRODUCTBRAND etc I also have another table called PRODUCTDETAILS which is having the details for each product. The PRODUCTDETAILS table has values such as PRODUCTDETAILSID, PRODUCTID, SIZE, COLOR For example the product can be a t-shit and the PRODUCTDETAILS table is able to hold some details about the t-shirt, such as SIZE, COLOR etc. I want to make the PRODUCTID filed of the PRODUCTDETAILS table as a foreign key of the PRODUCTID of the PRODUCTS table but i cannot find how to do it in phpMyAdmin Anyone for help.... Quote Link to comment https://forums.phpfreaks.com/topic/40436-phpmyadmin-foreign-keys/#findComment-196386 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.