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 Sendedemailsof 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 don't like user_name. , 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.sqlindicates 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