Creating foreign key in phpmyadmin mysql
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.
Hashim Adel
Member of the world's Upper Band with a theory of "More Innovation, More Opportunity"
Updated on July 09, 2022Comments
-
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 calledvoted_ip
and it has three columnsid
,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 columncomment_id
connecting it to the parent tablecomments
in the columnid
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 :
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?