Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the naming conventions in Mysql

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

What are the naming conventions in Mysql? in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Basic naming principles of Mysql

1. The use is named in English with the same or similar meaning, separated by an underscore, and it is recommended not to use pinyin.

two。 Database names, table names, and field names are all lowercase, do not use hump naming.

3. You can only use literal letters, numbers, underscores, and start with a letter.

4. Do not use database keywords and reserved words.

5. It is forbidden to have more than 32 bits in named fields. In principle, it is necessary to see the meaning of the name.

Common naming conventions for Mysql

1. Database names and table names are recommended with corresponding prefixes, such as temporary tables with tmp_ as prefixes, backup tables with bak_ as prefixes, log tables with log_ as prefixes, and information tables with inf_ as prefixes.

two。 Write a clear comment while the field is defined to avoid fields without comments.

3. Meaningful English words should be used in field naming, and the next [youdao Dictionary] is suggested.

4. The field with Boolean meaning is usually prefixed with "is_", followed by the past participle of the verb.

5. The foreign key field represents its association with the table name _ field name.

6. The primary key of a table is generally agreed to be id, and the self-increasing type is that the foreign keys of other tables are indicated by xxx_id.

7. When naming an index, the non-unique index must be named according to "idx_ field name field name [field name]", and the unique index must be named after "uniq_ field name field name [field name]"

8. When the constraint is named, the primary key constraint: pk_ table name. Unique constraint: uk_ table name _ field name. (uniqueness checking logic is required in the application at the same time.)

9. When the trigger is named, the trg_ table name _ action.

10. When naming a function process, it uses the form of verb + noun to express its meaning.

11. The name of the seq_ table when the sequence is named.

Database environment

Dev: development environment, development can read and write, table structure can be modified. Developers can modify the table structure, and the data in it can be modified at will, but they need to ensure that it does not affect other developer colleagues.

Qa: test environment, developers can read and write, developers can modify the table structure through tools.

Sim: simulates the environment, develops read / write, and initiates an online request, which is first pre-executed on this environment. This environment can also be used for deployment of online drills or stress tests.

Real: production database slave database (quasi-real-time synchronization), read-only environment, does not allow to modify data, table structure modification, for online problem search, data query and other use.

Online: online environment, developers do not allow direct online environment for database operations, if the need for operations must find DBA for operations and corresponding records, prohibit stress testing.

The machines in these environments must have a clear division of permissions, separate read and write accounts, have a degree of identification, and be able to distinguish specific businesses. For example, the user name "read _ write" r _ account represents a read and write account, and account is a read and write account.

This is the answer to the question about the naming conventions in Mysql. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report