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”
Leave a Reply