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 6544399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:27:39+00:00 2026-05-25T11:27:39+00:00

Ok this might be a brain dead question but I am curious. I often

  • 0

Ok this might be a brain dead question but I am curious.

I often find I have a situation where I need to store 1 of 3 values in a database. For example if my application asks “Is this house for sale?”, the user needs to be able to say “yes”, “no” but sometimes the user doesn’t know. So there is also “I don’t know”.

I am always tempted to set my data type as Boolean, but of course that only gives me yes or no and usually this is set to no for default.

I am curious as to what data type is set as common practice in this scenario?

I could use an integer and store “1”, “2” or “3”. Or I could store a string value, or , or ,or.

This is probably a silly question and there maybe a million ways that this is done. but if anyone knows a best practices method and why that would be helpful. Thanks.

  • 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-05-25T11:27:39+00:00Added an answer on May 25, 2026 at 11:27 am

    In a database a boolean value can actually expresses three states – true, false, and NULL (provided you allow NULL in the column).

    Use NULL for “I don’t know”.

    (And probably set the default for the column to NULL as well)

    EDIT: Thinking about this for a moment though, this can be problematic depending on your use case. Some high level languages (Java, for one) would end up converting the NULL to false in the query result set.

    ::shrug:: Use a varchar(1) (‘t’,’f’,’u’) or the smallest integer value available (for space considerations) … either is fine.

    Using an enum is another option, but be aware that it isn’t portable (Oracle being the notable problem child).

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

Sidebar

Related Questions

This might be a simple question but I've searched and searched and can't find
Greetings, Might be having a brain fart this morning, but I need a way
Alright, this is melting my brain. It might have something to do with the
This might seem like a very easy question for some of you folks, but
This might be a very basic question but it confuses me. Can two different
This might sound like a stupid question but just trying to learn something here.
This might have to be broken down a bit but what i want to
This might be a general mvp places and activities question, but the show case
This might sound rudimentary but, I have created tables by running queries in Workbench
This might be a brain fart, since it's a late day, but I'm stuck

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.