mySQL design question

I’m new to database designing… I’m wondering what would be the better choice to implement, say, something similar to a “thank you” in forum posts where multiple users can give thank to 1 post.

Between storing each users id all in the same row and separate by comma?

table - "post"

id       thank            post      etc

46     1,2,3,4,5,etc      text      xxxx

or multiple table with foreign key?

table - "post"

id - 46

table - "thank"

post id     user id

46           1

46           2

46           3

Is the former with comma being used at all? If so, what is the practical way to use it? Use PHP to explode the comma?

Your first suggestion looks like how some guys (including myself) did it about 15 year ago, when they had no idea, how to do it right :D

So go for number two! And also do some google research on “database normalization”. You should find a lot of good tutorials. It’s a very common issue.

A minor performance tweak would be like a combination of the two: use a table to store all thank yous, and add an additional counter column that you increase every time you insert a thank you. This way it’s easier to get the total number of thank yous (without having to join other tables). On the other hand this adds some redundant information to your DB - which some would consider as a mistake in DB layout.