0

I have a table with two columns. State and Name. State can have two values, 0 and 1. When the state is 1, there needs to be a value in the column Name. If the state is 0 the Name must be null.

My question is what is considered as a good database design. I've come up with two options.

  1. Remove the column state and just distinguish the state whatever the Name value is null or not.
  2. Have the column State distinguish the state. But then I need to somehow enforce not null values in the case state is 1.
2
  • Does the column 'State' serve any function other than to denote whether 'Name' should be null or not? If not, 'State' seems superfluous. Commented Aug 30, 2017 at 9:19
  • No, it doesn't.
    – user49126
    Commented Aug 30, 2017 at 9:50

1 Answer 1

2

Based on your comment, I would suggest that the addition of the 'State' column adds additional application complexity (constraints necessary to keep the 'State' column in sync with the value in the 'Name' column) for, what appears to be, no added benefit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.