MS SQL Development naming convention

Source: Internet
Author: User
Tags naming convention save file

The following SQL development naming rules are my own development, summarized, collated out, the future development process will continue to improve, modify. Also hope that all netizens pointing, criticism.

Program: SQL statement keyword all uppercase, naming rules recommended to use Pascal case or each word using underscore _, not recommended to use all lowercase. Use fewer special characters such as numbers, spaces, etc.

Pinyin is not recommended for use in English or English abbreviations. Try to be as famous as you know.

1: Database name naming rules

(1.1) database name with the product name or project name as far as possible with the noun, see name know: myassistant my personal assistant Cndwdatacenter

2: Database table naming rules

(2.1) According to the function of the table, the content to name: For example, a table to save the user information, named users, save the sent message information named: Emails or Sendedemails

Of course, it has to be decided according to the circumstances, in different circumstances discretion. There are some tables in our project that are collected from other libraries (more),

Naming rules for these tables: {Server id}_{table name} or {server id}_{table name}_{Month}, etc., the principle is to be as fit as possible to the project, make easy to manage and clear the table function. The name of the table is in Pascal case or the word underlined, personally inclined to Pascal cases

(2.2) The names of the columns in the table such as user names, nicknames, ages, genders, etc. UserName, nickname, age, sex, I do not like user_name this writing, because with UserName I Already know the meaning of this field very clearly, there is no need to get an underscore.

(2.3) Temporary table ##{content} not necessarily # #Tmp {content}

3 Database View Naming conventions

Consistent with table naming rules, it is not recommended to precede the V

4: Stored procedure naming rules:

{usp}_{project name}_{module name}_{describing function}

{usp}_{module name}_{function}

{usp}_{describing stored procedure functions}

5: Function naming rules

Start with ufn_, describe function function eg Ufn_fromunixtimestamp

6: Trigger naming rules

{tg}_{table name}_{instead}_{column name}

{tg}_{table name}_{after}_{column name}

Or

{tg}_{table name}_{insert}_{column name}

{tg}_{table name}_{update}_{column name}

7: User type naming rules

{ut}_{name}

8:primary KEY Naming conventions

{pk}_{table name}_{field}

9:foreign Key Naming conventions

{fk}_{The referenced table name}_{the current table name}_{field}

10:default Constraint Naming conventions

{df}_{table name}_{field}

11:rule Constraint Naming conventions

{rl}_{table name}_{field}

12:unique Constraint Naming conventions

{uq}_{table name}_{field}

---------------------------------------------------script to save the naming rules--------------------------------------------------------

Create a table script to save file naming rules

{db instance ip}_{DB instance name} _{table name}

Create an attempted script to save a file naming convention

{db instance ip}_{DB instance name} _{attempted name}

Stored procedure save file name:

{IP address (last paragraph too long)} _{database name} _{stored procedure name} + {[Date (optional, if there is a different version of the same stored procedure saved)]}

Eg:147_crm_usp_edmdataanalysis.sql

Indicates that the stored procedure is: Stored procedure of CRM library under 121.10.140.147 database server

function save file naming rules

{db instance IP last segment}_{DB instance name} _{function name}


MS SQL Development naming convention

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.