• Uniform character encoding and comments: Use utf-8 or utf8mb4 encoding to store and represent all characters to ensure that tables and fields have clear annotation information.
• Control table data amount: Control the size of the data amount of a single table, and control the data amount of a single table within 8 million rows. The size of a single table data can be controlled by historical data archiving and sharding.
• VARCHAR stores variable-length strings up to 5,000. If the storage length exceeds this value, use TEXT and mark it independently.
• To store strings of almost equal length, the fixed-length string type CHAR should be used.
• Processing of associated columns: Place the columns that are often used together in the same table as much as possible to avoid excessive association operations and improve query efficiency.
• Compared with using character strings, using the datetime and timestamp types are better ways to store time because they are more accurate and efficient in processing time.
• The table should contain three required fields: ID (primary key), create_time (creation time), and update_time (update time).
• Avoid big transactions as much as possible: This reduces the long-term locking of resources and improves concurrency performance.