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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:18:42+00:00 2026-06-05T12:18:42+00:00

I took a long (over a year) break from database design and im just

  • 0

I took a long (over a year) break from database design and im just comming back.
I am designing a database for the website that i am creating. I am storing 2 boolean values in one table (two separate columns). I realized that if first value is true the other one will also always be true but if the first value is false the other one can be true or false. As far as im concerned this is not a transitive dependency and I shouldn’t create a new table but I want to make sure that I’m doing everything right. If there were multiple values that behave like the second boolean value would I still keep it in the same table?
What is the best way to store this kind of data in a database?

I would appreciate if the anwser included an ER Diagram.

  • 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-05T12:18:44+00:00Added an answer on June 5, 2026 at 12:18 pm

    Normalized:
    I think we should distinguish two cases:

    • max length of a sequence of boolean values == 2;
    • max length of a sequence of boolean values > 2;

    The first case can be solved using a single table with two fields, since it guarantees both good performance and space optimization (you can’t save more space than this way, except if you ignore Normalization Rules, which I did in the last of these solution):

    MyBools (id, firstBool, secondBool);
    

    Concerning the second case I came up with two ideas, none of which I’m satisfied with.
    The main thing we can say is that when you have long sequences, a column for each boolean value isn’t very handy. Here are my two ideas:

    1. a single table with a PK, a boolean field and a self-referencing foreign key:

      MyBools (id, thisBool, idNextBool);
      

      thisBool clearly contains a boolean value.
      If thisBool is true you’re done, you don’t need to store the following boolean value, since its value matches the first one.
      If thisBool is false idNextBool points to the following boolean.
      This solution allows forward-search only.

    2. a single table with a PK, a boolean value and a self-referencing foreign key:

      MyBools (id, thisBool, idNextBool);
      

      If idNextBool is null, you’ve reached the first value of the sequence. Otherwise idNextBool points to the following boolean.
      This solution allows backward-search only.

    As you can see the solutions for the second case (sequences longer than 2 values) are rather un-manageable.
    That’s why I propose a non-normalized solution.


    Not Normalized:
    You could treat these boolean values as bits of a numerical field (especially considering that a boolean is in fact represented by a bit). Let’s say we have two fields, field1 and field2, and consider that we can put them in one single field (let’s call it myfield):

    1) IF field1 is True THEN field2 True         myfield = 0
    
    
                                       __ True      myfield = 10
    2) IF field1 is False THEN field2 /
                                      \__ False       myfield = 11
    

    As you can see you can extend this to as many boolean values as you can fit inside a numerical field (for example in a 32bit numerical field you can store 32 boolean values, as long as each one depends on the lower ones).

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

Sidebar

Related Questions

We took over a website from another company after a client decided to switch.
Long story short, I took over a project and a table in the database
My server database took too long to run two sql queries by separate thread.
I took over a Visual C++ project in Visual Studio 2005 from a colleague.
A long time ago I took over maintenance of a web based content management
I took over a C++ code which is in a solution. That one solution
I just started making a database for my website so I am re-reading Database
I took over an old HTML based site with all hard coded links, no
I took the following code from the examples page on Asio class tcp_connection :
EDIT I'm understand the table is a mess. I took over this project and

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.