This is my table structure
Code:
CREATE TABLE `poll_results` (
`PollID` bigint(20) NOT NULL,
`UserID` bigint(20) NOT NULL,
`OptionNo` int(11) NOT NULL,
`Entry` datetime NOT NULL,
PRIMARY KEY (`PollID`,`UserID`,`OptionNo`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
The reason for `OptionNo` included for PK is to use it for multiple-select polls.
I have the first entry in a `Users` table with UserID = 0 is for Anonymous user.
How do I get this to work such that its
PRIMARY KEY (`PollID`,`UserID`,`OptionNo`) for every `UserID` thats not 0 and
PRIMARY KEY (`PollID`,`OptionNo`) for every `UserID` thats 0.
Thanks