음... 실제 표준으로 제정된건 아니고, 글 쓴사람이 제안하는거 같은데...

괜찮은거 같아서...

울 회사에서도 어느 정도의 naming rule을 정해서 개발을 하고 있는데(물론 어기는 사람도 가끔 있지만 --;;) 여러모로 장점이 많은데...

이 글에는 울 회사에서 사용하지 않는 rule도 있어서 함 소개합니다.

 

출처 : http://www.sqlservercentral.com/columnists/sjones/codingstandardspart1.asp

-------------------------------------------------------------------------------

 

  • Databases

    Each database on a server should be named using a name that is logical and applicable to the use of the database. Since third party databases often require specific names, this specification cannot give more concrete examples of naming standards. If you are building software which may be deployed on another server, you may wish to prefix the database name with some acronym signifying your company, as in example 3.

    Examples:

    • Sales
    • Dynamics
    • IBM_SalesAnalysis

  • Backup Devices (Full Backup)

    Any file that contains a complete backup should be named in the following format:
    <database name>_<4 digit year><month><day><hour><minute><second>
    where all times are the time the backup was started. The extension for all full backup files should be ".bak". All items should include leading zeros for values whose size is less than the size of the maximum value, i.e. always include a 2 digit month.

    Examples:

    • Sales_20011015080000.bak
    • Dynamics_20010908000000.bak

  • Backup Devices (Differential Backup)

    Any file that contains a differential backup should be named in the following format:
    <database name>_<4 digit year><month><day><hour><minute><second>
    where all times are the time the backup was started. The extension for all full backup files should be ".dif". All items should include leading zeros for values whose size is less than the size of the maximum value, i.e. always include a 2 digit month.

    Examples:

    • Sales_20011015083000.dif
    • Dynamics_20010908120000.dif

  • Backup Devices (Transaction Log Backup)

    Any file that contains a transaction log backup should be named in the following format:
    <database name>_<4 digit year><month><day><hour><minute><second>
    where all times are the time the backup was started. The extension for all full backup files should be ".trn". All items should include leading zeros for values whose size is less than the size of the maximum value, i.e. always include a 2 digit month.

    Examples:

    • Sales_20011015081500.trn
    • Dynamics_20010908080000.trn

  • Logins

    All login names should follow the company standards for network login names. Currently the standard is:
    <first initial>_<last name><middle initial (if needed)>

    Examples:

    • sjones
    • bknight

  • Users

    All database user names should match the login name to which it is mapped. NO User accounts should be shared among multiple logins. Use roles instead.

    Examples:

    • sjones
    • bknight

  • Roles

    All database roles should be named for the function of the role. This may be the name of the department or the job function.

    Examples:

    • Marketing
    • PurchasingAgents

  • Tables

    All tables should be named for the function of the table. For multiple word tables, the name should be in proper case for each word. No spaces should be used in table names.

    Examples:

    • Orders
    • OrderLineItems

  • Columns

    Columns used in either tables or views should follow the same naming convention as for tables. Proper case all words with no spaces inside the name.

    Examples:

    • OrderID
    • ProductCode
    • QuantityPurchased

  • Views

    All view names should begin with a lower case "v" and then follow the same naming conventions as for a table. Proper case all words in the name with no internal spaces. If this is a view of a single table and contains all fields, then use "v" plus the table name.

    Examples:

    • vOrderDetails
    • vProduct

  • Indexes

    All indexes should be named in the following format:
    <Table name>_<index type><index number (optional)> where the table name matches the table or view to which the index is being applied. The index types are:
    Primary Key - PK
    Clustered Index - IDX
    Nonclustered Index - NDX
    Only when there is more than one nonclustered index should the index numbering be used.

    Examples:

    • Orders_PK
    • Products_IDX
    • ProductDetails_NDX
    • ProductDetails_NDX2

  • Triggers

    All triggers should contain the name of the table, an underscore followed by "tr" and the letters which represent the intention of the trigger (i for insert, u for update, d for delete). If there are more than one trigger, a numerical designation, starting with 2 should be appended to the name.

    Examples:

    • Customers_tri
    • Orders_triu
    • Products_trd
    • Products_trd2

  • User Defined Functions (UDFs)

    A user defined function should prefixed by "udf_" and then a description that logically follows the function process. The description should be proper case words with no spaces.

    Examples:

    • udf_GetNextID
    • udf_SumOrderLines

  • Defaults

    All defaults should be prefixed with "df_" and then some description of the default value. The description should be proper case with no spaces or underscores.

    Examples:

    • df_One
    • df_GetDate

'programming > MSSQL' 카테고리의 다른 글

[세미나]SQL 고급과정 세미나 7th  (0) 2003.12.15
Reusing Identities  (0) 2003.12.09
Calling COM Objects From T-SQL  (0) 2003.12.09

+ Recent posts