Jump to content

phpMyAdmin & Foreign Keys


phpfan

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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....  :-[

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.