How best to think about keeping "cool""not cool" for articles or posts in the database?

0 like 0 dislike
41 views
For example, can vote for one post from the same ip address, the base of the shell, of an innoDB table.


We need to organize the storage of votes in the database with the least overhead and maximum speed rating calculation for the article.


I think the table structure is the following:


article_id (int 11)

ip (varchar 15)

mark (enum ("-1","1"))


The PrimaryKey for the first two fields. Most likely, it can be easier, share your experiences, please.
by | 41 views

3 Answers

0 like 0 dislike
Well if you only need to consider, it is enough just to add rating field in the table article and increase / decrease its value programmatically.
\r
The table is only needed when you want to impose a time limit Ah-PI the address, and so it is considered Good practice not to store the IP address as a string and write its numeric value (if you write in php php.net/manual/en/function.ip2long.php).
\r
Moreover, when outputting the news feed is very useful aggregatirovanie the rating value has to be stored in a separate field in the table articles — that would not be recalculated each time. To update it you can trigger on the side of the DBMS or software.
by
0 like 0 dislike
by ip is not very good because some providers on a bunch of users immediately hang up 1 ip, and the users of the mobile Internet so generally often 1 ip on all
\r
IMHO you'd better get decent to set a cookie with some unique token, and for her to watch than the ip
by
0 like 0 dislike
In addition to the previous speaker, the sad experience — from cheating to get impossible. You can only minimize it by a set of administrative and technical methods.
by

Related questions

110,608 questions
257,186 answers
0 comments
32,904 users