MySQL metadata for table rows
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 f开发者_高级运维or your help!
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
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
精彩评论