Performance optimization of MySql database Schema design: standardized object naming

The canonical naming itself does not have any impact on performance. A separate section is listed here, mainly because it is a content that is not highly valued, but has a great impact on the subsequent database maintenance. Just like some of the programming languages 不成文编码基本规范, although they did not see too many benefits when they were first used, they would be regarded as a kind of restraint, but when everyone took over and maintained a piece of code that was written very irregularly , I guess most people will be very depressed, and even scold the original writer in their hearts. In fact, any system is the same. There are no norms to follow. A completely unreliable style will only leave a confusing mess for future generations (or even yourself), and it is difficult to maintain.

The naming convention for database objects can actually be very simple, and there is no strict uniform regulation in the industry, and it only needs to be uniform enough within a company.

Generally speaking, I personally suggest that you need to pay attention to the following aspects:

  1. 数据库和表名应尽可能和所服务的业务模块名一致;
    In this way, DBAwhen the maintenance-related database objects, the new developer program development process, related technologies (non-technical) staff organize business logic and data relationships, we both can be very easy to understand the relationship between them.

  2. 服务于同一子模块的一类表尽量以子模块名(或部分单词)为前缀或后缀;
    Adding a prefix or suffix to a table of similar functions also allows all types of people who view and use the table to quickly associate the corresponding function and related business according to the name of the related object. Whether it is from a maintenance point of view, or from a use point of view, it will bring great convenience.

  3. 表名应尽量包含与所存放数据相对应的单词;
    This is especially important for new employees. If you want to be familiar with the data as soon as possible, understand the related business as soon as possible, and quickly locate the meaning of the data corresponding to each table in the database is very helpful.

  4. 字段名称也尽量保持和实际数据相对应;
    The meaning of this point I think you readers should be very clear, each table will have a lot of fields corresponding to the various attributes of the data, to understand the meaning of their respective representatives, in addition to the complete and standardized documentation, naming Clear and reasonable field names are also a useful supplement and more direct.

  5. 索引名称尽量包含所有的索引键字段名或者缩写,且各字段名在索引名中的顺序应与索引键在索引中的索引顺序一致,且尽量包含一个类似于 idx 或者 ind 之类的前缀或者后缀,以表名其对象类型是索引,同时还可以包含该索引所属表的名称;
    Do the biggest benefit is that DBAduring maintenance can be indexed by name to understand that most of the information in the index very direct clear.

  6. 约束等其他对象也应该尽可能包含所属表或其他对象的名称,以表名各自关系

The above list is just a relatively rudimentary specification suggestion. Readers and friends can make their own naming conventions according to the habits of their respective companies, as long as they are applicable. There are not many specifications, but practicality. And once the specifications are formulated, they must be strictly implemented in accordance with the specifications, otherwise it will become a garish without any practical significance.

Reference: " Mysql Performance Tuning and Architecture Design Notes "

Guess you like

Origin blog.csdn.net/Java_Caiyo/article/details/115055070