This article is half-done without your Comment! *** Please share your thoughts via Comment ***
Prepared by Bihag Thaker
Prefix the View Name with ‘vw_’
Try to include only letters in identifiers by using Pascal Casing and avoid the use of special characters in identifiers. Underscore (_) character may be used for element separation in an identifier.
Here element means Application Prefix, Group Name, Table Name or Entity Name etc. However, word separation in single element should be achieved with PascalCasing only.
Use proper, meaningful and self-explanatory identifiers for Views. Views are used for SELECT operations.
Following naming convention should be used for view: ‘vw_’ +
+ ‘_’ + + / Here, part can be optional. can generally a verb like ‘Get’ or ‘Select’ and so on. can be optional additional description. Some of the examples are:
12 vw_Sales_GetOrderDetailsForTodayvw_Sales_GetOrderDetailsTotalByCustomerID
Use schemas to separate different sets Views across multiple applications when possible. For example, if schema Sales is used instead of ‘Sales_’ as Application Prefix, then above Views should be as follows:
12 [Sales].[vw_ GetOrderDetailsForToday][Sales].[vw_ GetOrderDetailsTotalByCustomerID]
When queries are frequently executed which require complex joins and calculations, then you should implement them in view. Consider creating views when same complex queries are executed from the different part of applications.
Whenever possible, create views that are schema bound.
Following is the sample template of a stored procedure. It has been provided here only to have a basic idea of coding structure and standards that a stored procedure should follow:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
CREATE VIEW [dbo].[vw_ViewName] AS /* **********************Creation Details********************** View Name : [dbo].[vw_ViewName] Purpose : Get all Items along with totals. Author : Author Name Created On : 2017/01/01 *****************************Revision Details***************************** Project/ Revision No. Changed On Changed By Change Description ------------ ---------- ---------- ------------------ 1234 2017/08/08 Mr. ABC Two Columns Column1 and Column2 added. 1235 2018/01/13 Mr. XYZ Caculation added. */ --SELECT Query goes here |
Leave a Reply