Q
Q
Qeinzo2021-11-11 17:36:51
Database
Qeinzo, 2021-11-11 17:36:51

Is it better to use NOT NULL everywhere?

Do I understand correctly that it is best to use NOT NULL wherever possible? I understand that NULL is sometimes necessary (for example, when we add a product to the site, but we don’t know the price yet - this field can be made NULL), but if you look at the whole picture, what is the best thing to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2021-11-11
@Qeinzo

It is better to do what the business logic requires. If there can be no price, obviously it should be NULL. Because 0 and NULL are completely different values: "free" and "no price", which means that in the first case the goods are sold for free, and in the second case they may not be sold.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question