Disclaimer: I know that datatypes are a little bit subjective to which scripting/programming language you are using, I like to write in Python as a matter of preference; though I am happy to hear about any lanugage/implementation.
What is the best datatype to store a three-state variable? Something capable or representing Positive, Neutral, and Negative.
Example: Integers -1
, 0
, 1
.
- Pro: Very concise.
- Pro: Potentially efficient, Could be stored as a single 2-bit signed integer.
- Pro: could be used as a scale, such as a floating point multiplier.
Example 2: 0
, null
, 1
(or any permutation)
- Pro: Non-neutral use case can be binary.
- Con: Requires dynamic datatype
- Con: Potentially not concise.
Example 3: +
, (empty string),
-
- Pro: Very concise.
- Con: May utilize string logic to determine state.
- Pro?: Intuitive graphical representation.
Perhaps there is some clever binary logic that can do something clever that I can't even imagine, perhaps there relies too much considerations of the use case.
Also, are there any considerations when adapting a ternary state to store in a database engine? Like Innodb for reference.