Creating a foreign key in phpmyadmin mysql

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

: 1. For comments, it is called comments and has three columns: id , name , comment 2. for the IP address of the user who made the rating, and it is called voted_ip , and 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 speed in order to confirm that it cannot evaluate again if it exists.

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

in the following way: the foreign key creation

I thought there might be another step, or I should do something in the php side of the project. What am I missing?

+4
source share
1 answer

Data is not inserted into another table "voted_ip" when inserted into a "comment" on their own, you must explicitly add this restriction, this is just a test not to add data to another table automatically.

+1
source

Source: https://habr.com/ru/post/1500478/


All Articles