Variable (object) naming
A Database:
1. Basic naming rules
Table 1. Base Database object naming
Database objects
Prefix
Tables (table) T
Field (Column) C
Views (view) VW
Stored procedure (Stored procedure) SP
Trigger (Trigger)
Indexed (index) IDX
Primary KEY (Primary key) PK
Foreign key (Foreign key) FK
Check constraint (check Constraint)
Default constraint (default Constraint)
User-defined data type (user-defined)
User-defined functions (user-defined function)
Tbl_
No
Viw_
Prd_
Trg_
Idx_
Pk_
Fk_
Ck_
Df_
Udt_
Fun_
2. About the naming convention
Variables (variables declared in T-SQL Programming), procedures (stored procedures or triggers, etc.), entities (tables, fields) should be named according to the entity meaning and process action they represent:
Table 2. Good naming and bad naming examples
A good name
Bad naming.
@CurrentDate
@ActivityCount
@EquipmentType
Prcalculatetotalprice
@D
@ActNum
@ET
@prRunCalc
A. Verb form: Verbs put in front, nouns put back. Eg:prd_getproductbyid
B. Do not use computer terminology, as far as possible to use the company business-oriented operation.
C. Using abbreviations
Depending on the requirements of the previous article, the process name based on the business description may become lengthy, such as the following:
Prcounttotalamountofmonthlypayments (calculates the total amount per month paid)
Prgetparentorganizationalunitname (get parent organization name)
Ø If you can find the abbreviation of a word in the dictionary, use this as an abbreviation, for example: Mon (Monday), Dec (December)
Ø You can delete the word vowel (except for the first letter of the word) and repeat the letter for each word to abbreviate a word. For example: current = crnt, Address = Adr, Error = Err, Average = AVG
Ø do not use a conflicting abbreviation (usually a phonetic ambiguity). such as B4 (before), XQT (execute), 4tran (Fortran)
3. Database naming
Named according to the actual meaning of the project
4. Table naming
"Tbl_" + name (name as much as possible with English words, capitalized in the first letter of each word)
5. Field naming
Table name (minus prefix) abbreviation + "_" + attribute name (first letter of each word capitalized)
Abbreviation: Wubi Chaizi method to take the letter
One word: Take the first four letters
Two words: Take the first two letters of each word
Three words: Take the first two words and the last two letters of the third word.
Four or more than four: take the first letter of the first three words and the first letter of the last word.
6. Naming the primary key
The primary key is for a table, not for a field, because the primary key is unique, and a table can have only one primary key.
A. General primary key naming: The name of the primary key is Pk_tablename.
B. Composite primary key: "Pk_" + "field name"
e.g.: Constraint pk_studentcourse Primary key (stud_id, cour_id)
Primary key Pk_studentcourse, contains two fields stud_id and cour_id
7. Foreign key naming
The name of the foreign key is the name of the table named Fk_ foreign key, which is referenced by the foreign key. Because the foreign key is the table from which the table is located, the above can be written as fk_ from the table name _ the primary table name.
8.Check constrained naming
"Ck_" + "Table name" "_" + "Field name"
e.g.: Ck_tbl_company_comp_zip
9.Default constrained naming
"Df_" + "Table name" "_" + "Field name"
e.g.: Df_tbl_news_news_hit
10. Trigger naming
"Trg_" + "table name" + "suffix"
A. Prefix-"Trg_", which describes the type of database object.
B. Basic section, which describes the tables added by the trigger.
C. Suffixes (_i, _u, _d), showing modification statements (Insert, update, and delete)
11. Stored Procedure naming
Naming rules: see Names and know the meaning.
"Prd_" + "description"
Description: Dynamic object structure (verb + noun)
e.g.:p Rd_getproductbyid
12. Naming parameters in stored procedures
The first word is lowercase, with the same field name as the corresponding one.
Two. Program Design
Microsoft 3.0 documentation is the main
1. Project Name
"Company Name" + "project actual meaning name"
E.g.:qikingyellowpage
2. Page naming
Rule: Capitalize the first letter of each word because it is a class.
A. Parent page--using nouns to describe
B. Sub-page _ List--"list" + "Parent page"
C. Sub-page _ details--"Show" + "Parent page"
3 Page Pass Value
"Id_" + "page name"
4. Error page naming
Error.aspx
5. User Login
Userlogin.aspx
6. Folder naming
Capitalize the first letter of the word
Singular or plural, depending on actual needs.
Note: Some of these refer to the Zhang Ziyang database object naming reference Second editionhttp://www.cnblogs.com/jimmyzhang/archive/2007/08/30/875504.html
This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/gideal_wang/archive/2009/09/27/4600218.aspx
Green channel: Good text to the top concern my collection this article contact meSmileyearn
Follow-2
Fans-1+ Add attention00(Please comment on the article)» Next post: Database Restore
Database Design-Naming conventions _ Picks