What field type is best to use to represent status in the database?

WBOY
Release: 2023-03-01 15:34:02
Original
4366 people have browsed it

Although I have been using tinyint to save in the past, I found that if the business logic changes frequently, the order of numbers will be disrupted, and it will become difficult to identify with the naked eye. If you execute SQL statements directly in the database, you have to check the corresponding constant configuration instructions
I found a lot Foreign open source programs use character storage states.

Reply content:

Although I have been using tinyint to save in the past, I found that if the business logic changes frequently, the order of numbers will be disrupted, and it will become difficult to identify with the naked eye. If you execute SQL statements directly in the database, you have to check the corresponding constant configuration instructions
I found a lot Foreign open source programs use character storage states.

No one dares to guarantee that the invoice business will not change. The best database design is to use string storage (although performance may be sacrificed)

It is recommended to use enumeration type enum

In this case, you can consider using enumeration: enum type

comment Just write the comment clearly and don’t overwrite the previous one

enum or tinyint

Use int

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template