Setting up foreign keys in phpMyAdmin

Step 1:
You have to add the line:
default-storage-engine = InnoDB
under the [mysqld] section of your mysql config file (my.cnf or my.ini depending on your OS) and restart the mysqld service.

 

 

 

 

 

 

 

 

 

Step 2:
Now when you create the table you will see the type of table is: InnoDB

 

 

 

 

 

Step 3:
Create both Parent and Child table. Now open the Child table and select the coloum U like to have the Foreign Key:
Select the Index Key from Action Label as shown below.

 

 

 

 

 

Step 4:
Now open the Relation View in the same child table from bottom near the Print View as shown below.

 

 

 

 

 

Step 5:
Select the coloumn U like to have the Foreign key as Select the Parent coloumn from the drop down.
dbName.TableName.ColoumnName

Select appropriate Values for ON DELETE and ON UPDATE

 

Advertisements

Leave a comment

Filed under General

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s