S
S
sazhyk2019-02-25 15:54:06
PostgreSQL
sazhyk, 2019-02-25 15:54:06

What is better to store 0 or None in database?

Actually, what is better to store in the database 0 or None? And why so? Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
EVGENY T., 2019-02-25
@sazhyk

None is not 0 and not "", but type null is empty.
And what to store there depends on the logic of filling the field. For example, you store thermometer readings. Silly to store 0 in this case, if there is no data, agree. And the weight or height of a person is possible either way - there are hardly people with zero height or weight.

B
Boris Korobkov, 2019-02-25
@BorisKorobkov

5c73f77f3ffad303269457.jpeg

K
Krava, 2019-03-06
@Krava

In many cases it is better to zero and add a default value of zero, it often happens that you need to increase the value counter or some other mathematical operations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question