Dynamic counters - views, comments..
Posted: Tue Jan 02, 2007 10:37 am
Hello,
(sorry for my English
)
This is more a theoretical question, but i'd like to know from you, which is the best practice to implement dynamic counters for media or stuff (i mean, view count for photos, videos, blog entries etc.), but only UNIQUE counters, so pressing F5 won't add "+1".
For now I have table structure MEDIAID,USERID,DATE where I insert which user which media watched or read. For week running a project, I have > 30000 entries.
So on every media opening, there is "SELECT id FROM views WHERE userid=x AND mediaid=x" and if not, "INSERT INTO views...", then runs triiger "AFTER INSERT ON videos UPDATE videos SET views=views+1" and view count now i get from videos table.
So i shared my practice, and like to know is there something more optimized in the world?
Thank You All.
(sorry for my English
This is more a theoretical question, but i'd like to know from you, which is the best practice to implement dynamic counters for media or stuff (i mean, view count for photos, videos, blog entries etc.), but only UNIQUE counters, so pressing F5 won't add "+1".
For now I have table structure MEDIAID,USERID,DATE where I insert which user which media watched or read. For week running a project, I have > 30000 entries.
So on every media opening, there is "SELECT id FROM views WHERE userid=x AND mediaid=x" and if not, "INSERT INTO views...", then runs triiger "AFTER INSERT ON videos UPDATE videos SET views=views+1" and view count now i get from videos table.
So i shared my practice, and like to know is there something more optimized in the world?
Thank You All.