Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:14:26+00:00 2026-06-11T10:14:26+00:00

My database knowledge is reasonable I would say, im using MySQL (InnoDb) for this

  • 0

My database knowledge is reasonable I would say, im using MySQL (InnoDb) for this and have done some Postgres work as well. Anyway…

  • I have a large amount of Yes or No questions.
  • A large amount of people can contribute to the same poll.
  • A user can choose either option and this will be recorded in the database.
  • User can change their mind later and swap choices which will require an update to the data stored.

My current plan for storing this data:

  • POLLID, USERID, DECISION, TIMESTAMP

Obviously user data is in another table.

To add their choice, I would have to query to see if they have voted before and insert, otherwise, update.
If I want to see the poll results I would need to go iterate through all decisions (albeit indexed portions) every time someone wants to see the poll.

My questions are

  1. Is there any more efficient way to store/query this?
  2. Would I have an index on POLLID, or POLLID & USERID (maybe just a unique constraint)? Or other?
  3. Additional side question: Why dont I have an option to choose HASH vs BTREE indexes on my tables like i would in Postgres?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:14:28+00:00Added an answer on June 11, 2026 at 10:14 am

    The design sounds good, a few ideas:

    A table for polls: poll id, question.

    A table for choices: choice id, text.

    A table to link polls to choices: poll id->choice ids.

    A table for users: user details, user ids.

    A votes table: (user id, poll id), choice id, time stamp. (brackets are a unique pair)

    Inserting/updating for a single user will work fine, as you can just check if an entry exists for the user id and the poll id.

    You can view the results much easier than iterating through by using COUNT.

    e.g.: SELECT COUNT(*) FROM votes WHERE pollid = id AND decision = choiceid
    

    That would tell you how many people voted for “choiceid” in the poll “pollid”.

    Late Edit:

    This is a way of inserting if it doesn’t exist and updating if it does:

    IF EXISTS (SELECT * FROM TableName WHERE UserId='Uid' AND PollId = 'pollid')
        UPDATE TableName SET (set values here) WHERE UserId='Uid' AND PollId = 'pollid'
    ELSE   
        INSERT INTO TableName VALUES (insert values here)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wants to have some knowledge about how database management software is implemented. Is
This question is related to database/RDBMS where i have little knowledge regarding performance and
This question is just for my personal future knowledge since the database it applies
I'm no database expert, but I have enough knowledge to get myself into trouble,
I have a nightly database backup which I would like to scp to a
I have limited knowledge of php and mysql, I am trying to learn it
I have learned the language itself as well as html/css/javascript. But with no database
I have created a Database in DB2 and tables with relationships. I would like
I would like to play with a larger database to test my knowledge on
I dont have much knowledge in using the Cursor to read data of SQLite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.