Database Design -- Design Principles

Database Design -- Design Principles

 

 

       1. In general, you should try to use the smallest data type that can correctly store the data. Different data types have different storage execution efficiency. It is best to use a moderate integer data type, such as int, which is the fastest when doing queries or sorting fields.

 

       2. Try to avoid the use of NULL values, because this will increase the overhead of database processing. However, the actual situation should also be considered. Do not blindly set all to not null in order to avoid null values. The specific setting depends on the specific business of the project.

 

       3. Pay attention to the use of char and varchar. The size of char suitable for storage is basically fixed within a range, and data that changes infrequently. And varchar is different, varchar is suitable for data whose size is not fixed and does not change frequently. It should be noted that the length of the varchar definition should be just enough, otherwise it will be a waste of resources and affect the performance and storage space of the overall database.

 

       4. It can be marked with an integer, and it is better to use an integer mark, because it has the smallest overhead and the highest efficiency.

 

       5. A table field should be limited to a certain range, not too long, otherwise it will cost a lot when querying, it is best to divide it into commonly used and very used fields.

 

       6. When designing tables and query languages, it is necessary to avoid large-scale associated queries as much as possible, because this will seriously affect the query efficiency of the database.

 

       7. When designing the database, reasonable database tables and fields should be designed according to the specific business. Not just paradigms, but anti-paradigms as well. Without compromising data security and data redundancy, the design of hybrid paradigms can be properly considered.

 

       8. Use cache tables and summary tables to optimize database queries.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326132420&siteId=291194637