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

Naming rules for MS SQL development

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following naming rules for SQL development are summarized and sorted out during my own development, and will be continuously improved and modified in the future development process. I also hope that netizens can give us some advice and criticism.

Program: SQL statement keywords are all uppercase, naming rules recommend using Pascal Case or each word is separated by an underscore, not all lowercase. Use as few special characters as possible, such as numbers, spaces, etc.

Use English or English abbreviations. Pinyin is not recommended. Try to see the name and know the meaning.

1: database name naming rules

(1.1) use nouns for database names, product names or project names as far as possible. See the name: MyAssistant my personal assistant CndwDataCenter.

2: database table naming rules

(2.1) name according to the function and content of the table: for example, a table stores user information and is named Users, and the email message saved and sent is named Emails or SendedEmails.

Of course, it has to be decided on a case-by-case basis and dealt with at the discretion of different circumstances. For example, some tables in our project are collected from other libraries (more).

The naming rules for these tables: {server ID} _ {table name} or {server ID} _ {table name} _ {month}, etc., based on the principle that they are as suitable for the project as possible, easy to manage, and clear of the table's functions. Whether the table name is underlined with Pascal Case or words, I prefer Pascal Case.

(2.2) the naming of the columns in the table, such as user name, nickname, age, gender, etc. UserName, NickName, Age, Sex, etc., in the Users table. I don't like the way User_Name is written, because with UserName I already clearly understand the meaning of this field, so there is no need to make an underscore.

Temporary table # # {content} does not have to be # # Tmp {content}

3 naming rules for database views

Consistent with the table naming rules, it is not recommended to add V before it.

4: stored procedure naming rules:

{USP} _ {Project name} _ {Module name} _ {description function}

{USP} _ {module name} _ {description function}

{USP} _ {describe the functions of stored procedures}

5: function naming rules

Starts with UFN_, followed by a description of the 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 rules

{contention} _ {Table name} _ {Field}

9: Foreign Key naming rules

{FK} _ {referenced table name} _ {current table name} _ {field}

10: naming rules for Default constraints

{DF} _ {Table name} _ {Field}

11: naming rules for Rule constraints

{RL} _ {Table name} _ {Field}

12: naming rules for Unique constraints

{UQ} _ {Table name} _ {Field}

-script saves naming rules-

The script that creates the table saves the file naming rules

{Database instance IP} _ {Database instance name} _ {Table name}

Create an attempted script to save the file naming convention

{Database instance IP} _ {Database instance name} _ {attempt name}

Stored procedure save file name:

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

Eg:147_CRM_USP_EdmDataAnalysis.sql

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

Function save file naming rules

{last paragraph of database instance IP} _ {database instance name} _ {function name}

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