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

  • Home
  • SEARCH
  • 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 7793951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:38:57+00:00 2026-06-01T22:38:57+00:00

I have a table that holds rows representing votes. The fields are an id

  • 0

I have a table that holds rows representing votes. The fields are an id for the vote itself, an id for the thing that the vote is for or against and a direction field that holds “up” or down”. Would it be better to use 0 and 1 or 1 and 2 for “up” and “down”? Is it always better or worse to use string or integers in this way?

I have heard that integers can make certain table operations faster, but using integers in a context like this where the real thing that you’re trying to represent is a direction seems to introduce unwanted complexity when it comes to coding. If I go with integers, I’ll need to remember which number represents which direction and my code just won’t be self-documenting.

Any thought?

  • 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-01T22:38:58+00:00Added an answer on June 1, 2026 at 10:38 pm

    In your case storing and “UP” and “DOWN” as an integer wouldn’t be a bad idea, you can store the enumeration on a specific table that holds the possibles vote status.

    You can create a table called votes with an integer ID and a String vote like the following :

        votes
    +------+------+
    | id   | vote |
    +------+------+
    |  0   | UP   |
    |  1   | DOWN | 
    

    And then reference the ID of the vote when needed with a field called for example : vote_id ; i would prefer this approach rather than an enumerator because it is more flexible an scalable, for example if some day for some reason you want to add another type of vote you can do it easily and without touching your application code, but the implementation will be simple as create a new record in the votes table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table (table variable in-fact) that holds several thousand (50k approx) rows
I have a MySQL table that holds rows of configuration data, ie: id item
I have a database table that holds customer data with several million rows in
Given that I have a table that holds vehicle information and one of those
i have a table that holds my users information like username , password ,
I have a MySQL table that holds many entries with repeated IDs (for various
Lets suppose that I have a Category table with a column that holds the
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a table that has an AUTO_INCREMENT field. Currently, it is also a
I have a table which holds ~1M rows. My application has a list of

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.