|
Yes, I'd have an enum with Yes, No and Unset. Many languages have a typed "no value" value that is composable with other types: Maybe<T>, Option<T>, Nullable<T>. In other situations I might have an Option<Yes, No>, i.e. when I want a non-null value to indicate that it isn't Yes or No. The reason why I don't want a null, in general, is that it's the billion dollar mistake: https://hackernoon.com/null-the-billion-dollar-mistake-8t5z3... But if the user can actually choose "Unset", then that's a choice, too. "Unset" might, for example, have implications that other null-ish answers don't have in the future. As for SQL: I might go for a NULL for performance, knowing that if another neither-yes-or-no option with different implications came, I might have to migrate the NULLs. |
In the DB you would need to store incomplete records in a separate table, since they have different validation rules. Queries against the main table should be able to assume that all the records are complete.