General idea of database table design

1. Don’t do operator operations on the database.
    Database server resources are precious and should be cherished. If you perform operations such as rand() and md5() on the database, it will put a lot of pressure on the server under concurrency, so let the database do more. My favorite thing: try not to do calculations in the database, and transfer complex calculations to the CPU of the terminal, and use MySQL as simple as possible.
2. Reasonably control the data volume of the database table.
    The single database should not exceed 300 tables; the data volume of a single table should not exceed 5000W. If you want to achieve a better experience, the numerical INT type should not exceed 1000W, and the character type should not exceed 500W. When the amount of data exceeds a certain amount, sub-table and sub-database operations need to be considered.
3. Control the number of columns in the table.
    The upper limit of the number of fields in a single table is controlled within 40. For the excess, you can consider attaching a table or put it in other tables. If there are too many columns, it will be slow when inserting data, and it will also be slow when getting data.
4. The coexistence of three paradigms and redundancy
    does not mean that the column information of each table must be in accordance with the three paradigms, but that efficiency is prioritized and performance is improved. There is no absolute right or wrong. When appropriate, paradigms are sacrificed and redundancy is added.
5. Reject the three major settings of
    big SQL (BIG SQL); big transaction (BIG Transaction);

Guess you like

Origin blog.csdn.net/weixin_70855192/article/details/131325688