SQL design and naming rules

Source: Internet
Author: User
I. design Specifications: 1. use meaningful field names: Make sure that the field descriptions are clearer (meaning); 2. comply with the database three Paradigm (3NF): A: each value in the table can only be expressed once; B: each row in the table should be uniquely identified (with a unique key). C: The table should not store non-key information dependent on other keys. 3. Retain with caution

I. design Specifications: 1. use meaningful field names: Make sure that the field descriptions are clearer (meaning); 2. comply with the database three Paradigm (3NF): A: each value in the table can only be expressed once; B: each row in the table should be uniquely identified (with a unique key). C: The table should not store non-key information dependent on other keys. 3. Retain with caution

I. design specifications:

1. Use meaningful field names: try to clarify the field descriptions as much as possible (meaning );

2. comply with the database three Paradigm (3NF) Rules:

A: each value in the table can be expressed only once;

B: each row in the table should be uniquely identified (with a unique key );

C: The table should not store non-key information dependent on other keys.

3. Be careful when retaining words: ensure that your field names do not conflict with reserved words, database systems, or common access methods;

4. Avoid empty columns in the table;

5. Maintain the consistency of Field Names and types;

Ii. Naming rules

1. database definition:

Database Name = database content identifier (uppercase)

2. Table definition:

The name should reflect the stored data content as much as possible;

Table name prefix: The table is identified by the table and the content of a series of tables associated with the table;

Table name = table name prefix + Table content identifier (uppercase );

Comply with the following specifications:

The singular form is adopted in a unified manner. The objection is: ErpCsUsers;

Uppercase letters: American server. If multiple words are entered, the first letter of the word is capitalized. For example, erpCsUser/ErpCsuser/ErpCsUSER;

Avoid Chinese pinyin, such as ErpCsYongHu;

Avoid underline connection: disallow: ErpCs_User;

Avoid reserved words;

3. Fields

Comply with the following specifications:

The first letter is lowercase. If multiple words are entered, the first letter is capitalized, for example, userName, against UserID/useid;

There must be a primary key, and the primary key uses id directly;

The name/desc field is a common name/desc field. The Name/Desc is not used directly, but the table name + name/table Name + desc, for example, usrName/userDesc;

Uppercase letters must contain at least two lower-case letters;

Avoid Chinese pinyin;

Avoid underline connections;

Avoid too long names;

Avoid reserved words;

4. variable name:

The first letter is in lower case. If multiple words exist, the first letter of each word must be in upper case, for example, @ userName;

5. Object:

The prefix of the stored procedure is SP;

The trigger is prefixed with TR;

The function is prefixed with FN;

The primary key is prefixed with PK;

The index is prefixed with IX;

The first letter after the prefix is capitalized. If there are multiple words, the first letter of the word is capitalized, such as erpsp_countdigit;

All letters of all keywords must be capitalized, such as SELECT * FROM User;

6. Other considerations in naming:

Chinese naming is prohibited;

The name must not exceed the system limit of 30 characters. The variable name length must be 29 (excluding the identifier character @);

The name must be an English character. The first letter of each word must be an uppercase letter;

7. SQL statement writing specifications:

Uppercase keywords: such as SELECT, order by, group by, FROM, WHERE, UPDATE, SET, insert into, BEGIN, and END;

8. Content comment

Content annotations should be added to stored procedures, triggers, functions, and views;

A Brief Field description and content description should be added to the unfamiliar fields of the table;

, US space
Related Article

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.