Is it a normal practice when there’re 2 columns and if one is true the other must false, and vise versa

database-design

I have something similar to this, but not precisely it:

I sell only coffee and tea, and for the next 50 years I'll be selling only these. In a table "drinks" I have 2 columns: is_coffee? and is_tea?. Only one of these can be true, obviously, and if one is true, the other must be false.

Also, I have some columns that are specific to only coffee, when is_coffee? is true, and others to only tea.

Does it make sense hold all of them in a single table? Is it a normal situatation when there're 2 columns and if one is true the other must false, and vise versa?

Best Answer

This is called transitive functional dependency and should be avoided to have a 3th normal form design.

To solve it you should move it to the type of product to another table.

And then you can have another table linked with specific attributes of coffee entity and another one with specific attributes of the tea entity.

Don't be scared of the number of the tables, be scared of the consequences of not be in normal form. (i.e. lack of performance, space, scalability)