Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The answer to your question is "no". The bit fields sacrifice relational integrity, for the simple reason that you have entities in the database that don't have a corresponding tables.</p> <p>That said, many databases offer support for this, generally through a "bit" data type. Mysql has even stronger support, with the "set" data type.</p> <p>The primary issue is that you do not know anything about the elements in the set -- what the full name is, when it was added into the database, and so on. (Enums get around part of the naming problem.) In addition, the size of the set is limited. You may have an example where things are limited. However, Matt's example rather emphasizes the problem here. You can have a list of continents visited. However, when you switch to countries visited, the approach is necessarily quite different, because the number of countries no longer fits in a single "word". Would you want your system to treat continents very differently from countries in this respect? Do you want your design decisions to be restricted by the limit of 32 or 64 bits in a computer word?</p> <p>And finally, you seem to view the proliferation of tables as a problem. The proliferation of tables is actually a solution. All data about entities is stored in tables, rather than being spread out through the system. You can maintain information about instances of the entity, such as when the instance was created, how it might have changed over time, and so on. An entity for "continents" is likely to be used whenever someone wants a continent.</p> <p>Consider what happens in a system where two different developers decide to develop their own bit masks for continents -- but they put the continents in a different order. With a well designed relational database (meaning that foreign key relationships are explicitly declared in the table definition), such confusion could not arise.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload