Database design specification: Naming conventions

Source: Internet
Author: User
Tags table name

Naming conventions

Description: Refers to the naming conventions of database objects such as tables (table), sequences (SEQUENCE), Procedures (PROCEDURE), triggers (TRIGGER), and so on.

1. Basic naming principles

(1) Rule 1: Name the use of meaningful English words, the middle of the word is separated by an underscore.

(2) Rule 2: Names can only be used in English letters, numbers, underscores, and begins with an English letter.

(3) Rule 3: Avoid using Oracle, MySQL reserved words such as DESC, keywords such as index.

2. Table naming

(1) Rule 1: Tables of the same module use the same prefix whenever possible, and the table name expresses the meaning as much as possible.

(2) Rule 2: No more than 25 characters in length.

3. Field naming

(1) Rule 1: An English word or shorthand for expressing its actual meaning.

MySQL: Boolean field with "Is_" as the prefix, followed by the verb past participle.

(2) Rule 2: The same name should the same meaning between the tables.

MySQL: A field of the same meaning between tables, named after the table name _ field name that removes the module prefix.

(3) Rule 3: The Foreign key field represents its association relationship with the table name _ field name.

MySQL: Use of foreign keys is prohibited.

Example: log_prepay.id=log_account.prepay_id

Example (MySQL): Field Prepay_group.id is referenced by Prepay_contact, and the corresponding field in Prepay_contact table is named: group_id

4. Index naming

(1) Rule 1: Table name _ Field name _ind

Mysql:idx_ Table name _ Field name

Example: Index:employee_fid_ind on the employee table first_name

Example (MySQL): Prepay table agtphone_id and stream_id Index:idx_prepay_aid_sid

5. Constraint naming

(1) Rule 1: PRIMARY KEY constraint: Table name _PK.

(2) Rule 2: Unique constraint: Table name _ Field name _uk.

MySQL: Uniqueness constraints, except primary keys, can be implemented by creating a unique index prefixed with "Uk_", but the application requires both a unique check logic.

6. Trigger naming

(1) The Rule 1:trg_ table name _ operation.

7. Function procedure naming

(1) Rule 1: Use the form of verb + noun to express its meaning.

8. Sequence naming

(1) Rule 1:seq_ table name

Author: csdn Blog Guoyjoe

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/basis/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.