Creating foreign key in phpmyadmin mysql

31,102

Data is not inserted in the other table "voted_ip" on insertion in "comment" by itself you have to add it explicitly this constraints are just for checking not for adding data in other table automatically.

Share:
31,102
Hashim Adel
Author by

Hashim Adel

Member of the world's Upper Band with a theory of "More Innovation, More Opportunity"

Updated on July 09, 2022

Comments

  • Hashim Adel
    Hashim Adel almost 2 years

    Creating a comment system with a simple rating system for each comment.

    tables : 1.For the comments and it is called comments and it has three columns : id, name, comment 2. for the IP of the user that did the rating and it is called voted_ipand it has three columns id, comment_id, user_ip

    The purpose of the voted_ip table is that i need to save the IP address for each rate to validate it that it cannot rate again if it exists.

    I created a foreign key from the child table voted_ip in the column comment_id connecting it to the parent table comments in the column id following the steps at this link and this video on how to create a working foreign key except that the child table still do not update after a comment or a rate is inserted.

    as follow : the foreign key creation

    I thought about that there might be another step or I have to do something in the php side of the project. What am I missing?