You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATE KEYSPACE IF NOT EXISTS casspoll
WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
USE casspoll;
CREATETABLEIF NOT EXISTS Polls (
pollId uuid,
title text,
description text,
dueTime timestamp,
pollType int,
PRIMARY KEY (pollId)
);
CREATETABLEIF NOT EXISTS Answers (
answerId uuid,
answer text,
pollId uuid,
PRIMARY KEY (pollId, answerId)
)
-- idea #1-- "server" prevents from inserting due to exceeding the deadlineCREATETABLEIF NOT EXISTS Votes (
pollId uuid,
answerId uuid,
votesNo counter,
PRIMARY KEY (pollId, answerId)
);
-- voting-- now := time.Now().Unix()SELECT dueTime FROM polls WHERE pollId = ?;
-- if now < dueTime {}-- for answer := range selectedAnswers {UPDATE Votes SET votesNo = votesNo +1WHERE pollId = ? AND answerId = ?
-- }-- }-- calculating votes-- for answer := range answers {SELECT votesNo FROM Votes WHERE pollId = ? AND answerId = ?
-- }-- idea #2CREATETABLEIF NOT EXISTS Votes (
pollId uuid,
answerId uuid,
voterId uuid,
PRIMARY KEY (pollId, answerId)
);
-- voting-- now := time.Now().Unix()-- for answer := range selectedAnswers {INSERT INTO Votes (voterId) VALUES (?) WHERE pollId = ? AND answerId = ? USING TIMESTAMP now;
-- }-- calculating votes-- for answer := range answers {-- SELECT COUNT(*) FROM Votes WHERE pollId = ? AND answerId = ? AND writetime(voterId) < dueTime-- }SELECTCOUNT(*) FROM Votes WHERE pollId = ? AND writetime(voterId) < dueTime GROUP BY answerId
-- other options-- + Votes include text for answer, no need for Answers table
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: