here is a very simple mysql example:
drop table if exists image; create table image ( image_id int unsigned not null auto_increment primary key, caption varchar(255) not null, num_votes int unsigned not null default 0, total_score int unsigned not null default 0, rating decimal(8,2) not null default 0 ) engine = innodb; drop table if exists image_vote; create table image_vote ( image_id int unsigned not null, user_id int unsigned not null, score tinyint unsigned not null default 0, primary key (image_id, user_id) ) engine=innodb; delimiter
source share