key question

They have: 461 posts

Joined: Jul 2003

i used this to create a vote tracking table:

CREATE TABLE votes(
voteruid int unsigned NOT NULL,
voteeuid int unsigned NOT NULL,
vote float(3,1) NOT NULL,
INDEX voteruid (voteruid),
INDEX voteeuid (voteeuid),
INDEX vote (vote)
) TYPE=MyISAM;
' right now i have php check against a line with the two ids before adding a vote. i'm wondering if adding a unique key of the two ids would make one of them into a unique key. i know that if i make a key that's two it automatically makes the subsets of each group to the left into a key as well. thing is i want ppl to be able to vote on each person, just wanna restrict it to each user gets to vote on each user once. i can see ways a user can get two in on this (two well timed loads in different windows). so i'm wondering how to get it better. obviously i can't have any feild be unique

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Use "UNIQUE voting (voteruid,voteeuid)" to make sure that there is only one voter-to-votee pair.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.