Take the 2-minute tour ×

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?

share|improve this question
Post the schemas and the query. –  Mihai Sep 4 '13 at 9:37
Just so simple I did not write any queries I shared a screenshot though –  Hashim Adel Sep 4 '13 at 9:44
If it is really so simple, then how come that you have a question here? –  Lajos Arpad Sep 4 '13 at 10:35
That video link helped me! I was looking where relations are defined! –  Nirav Zaveri Jul 21 at 11:04

2 Answers 2

if i understand you correct you are looking for a way to alter voted_ip after in comments has happened insertion. I would suggest you to use triggers after insertion event on comments table.Check them out. Sorry if i have misunderstand you and this comment it's not helpful.

share|improve this answer

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|improve this answer

Your Answer


