Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2018 May SQL Server Coding Standards: About General Naming Conventions

SQL Server Coding Standards: About General Naming Conventions

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

Prepared by Bihag Thaker

To standardize the naming conventions for different objects in SQL Server for consistency across different applications using the same database, following naming conventions should be practised:

For user-defined tables: use the prefix ‘tbl_’ + name of the table. e.g. “tbl_OrderDetails”

For user-defined stored procedures: use the prefix ‘usp_’ + name of the stored procedure. Do not use prefix ‘sp’ as it is intended to recognize the SQL Server’s system stored procedures. e.g. “usp_DeleteCustomer”

For user defined views: use the prefix ‘vw_’ + Name of the view. e.g. “vw_GetOrderDetails”

For user defined functions: use prefix ‘udf_’ + name of user defined functions. e.g. “udf_ValidateEmailAddress()”

For triggers: use prefix ‘trg_’ + TableName +’_’ + ‘[INSTEADOF]/[AFTER]’ + ‘_’ + ‘INSERT/UPDATE/DELETE[_ INSERT/UPDATE/DELETE]’. e.g. “trg_tbl_Orders_AFTER_INSERT_UPDATE”

For Indexes: use prefix ‘idx_’ + TableName + ’_’ + ColumnNames separated with underscore (_) character. e.g. “idx_tbl_Orders_OrderDate”

For Primary Key Constraints: use prefix ‘pk_’ + TableName + ’_’ + ColumnNames separated with underscore (_) character. e.g. “pk_tbl_Orders_OrderId”

For Foreign Key Constraints: use prefix ‘fk_’ + TableName + ’_’ + ColumnNames separated with underscore (_) character. e.g. “fk_tbl_OrderDetails_OrderId”

For Unique Key Constraints: use prefix ‘uk_’ + TableName + ’_’ + ColumnNames separated with underscore (_) character. e.g. “uk_tbl_Customers_SocialSecurityNumber”

For Check Constraints: use prefix ‘ck_’ + TableName + ’_’ + ColumnName. e.g. “ck_tbl_OrderDetails_Quantity”

For Default Constraints: use prefix ‘df_’ + TableName + ’_’ + ColumnName. “df_tbl_Orders _OrderDate”

May 17, 2018Anvesh Patel
SQL Server Coding Standards: About Object IdentifiersSQL Server Coding Standards: T-SQL Query and Batch Practices

Leave a Reply Cancel reply

CAPTCHA
Refresh

*

Anvesh Patel
Anvesh Patel

Database Engineer

May 17, 2018 SQL Server, SQL Server Coding Standardsbasic sql commands, basic sql queries, coding best practices, SQL, sql basics, sql coding best practices, sql commands, sql database, sql formatter, sql language, SQL Programming, sql queries, sql queries for practice, sql query formatter, sql server format, sqlcode
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....