tags:

views:

24

answers:

2

Hi,

I have a question about how to save metadata for table rows.

For example, I have a table which contains data about images items_images. id, INT(20) title, VARCHAR(255) date_added, DATETIME ...

Now I want to add a voting system where users can vote "like" or "dislike" for the image items. Should I just add two new fields to the items_images: votes_like, INT(20) votes_dislike, INT(20)

or should I create a separate table to store this meta data votes: item_id, INT(20) votes_like, INT(20) votes_dislike, INT(20)

Thanks for your help!

+1  A: 

Don't repeat the data ! You are supposed to store who voted, right? You should create a new table like your later approach.

See:

Database Normalization

Sarfraz
+1 for the importance of normalization
DrColossos
A: 

As I understood it, you just want to save, the number of likes and dislikes and not who voted. Than I would alter the table and and the two columns, because it is slightly faster than a second table.

If you want to save the votes, I mean who voted, I totally aggree with Sarfraz Ahmed

TooAngel