| Business Application Development with: SQL Server, C#, VB, VB.Net, ASP, ASP.Net, and XML |
| N | S |
Novick Software Management • Design • Programming • Training • Consulting |
|
|
News Links Schedule Site Map Contact |
|
|
|
Group |
Description |
|
Dt |
Date and time functions |
|
Txt |
Character string functions |
|
BitS |
Bit String functions |
|
Tbl |
Table metadata functions |
|
View |
View metadata functions |
For dba_ stored procedures some groups are: Disk, Perf, ErrorLog, Permission, and Job.
So here are some typical names and a breakdown of the name.
| Name | Breakdown |
| v_AppSecurity_Users | View in the AppSecurity group that lists users |
| usp_AppSession_Purge | A user stored proc in the AppSession group to purge old data |
| udf_Tbl_ColInfoTAB | An inline (view type) UDF in the table group that gives column information. |
| udf_Sys_RegReadStr | A user-defined function in the system group that read a string from the registry. |
| AppSessionTrace | A table in the AppSession group that holds trace information |
| QuoteDetail | A table in the Quote group that holds the quote detail |
| v_iSeries_TMASTER | A view to the iSeries DB2 database to the TMASTER table |
| udf_Num_ToWords | UDF to translate a number into works |
| rpt_Empl_Anniversary | Stored procedure in the Employee group that returns the contents of the Anniversary report. |
| dba_Perf_Trace4Read80 | A stored procedure in the Performance group to create a trace for Read80Trace |
As you can see, every name doesn't follow all the rules exactly. The rules are bent in order to convey the meaning of the database object, which is the original purpose of the name.
In addition to the prefixes that I use indicate the type of object there are three additional prefixes that designate something about the stage of development for the object. They are:
Table 5 Lifestage Designators
|
Prefix |
Stage |
|
Adhoc_ |
Objects used for onetime analysis or staging. |
|
Wip_ |
A work in progress. |
|
Obs_ |
Obsolete objects. |
adhoc_ objects are intended for some one-time only purpose. For example, when loading test data, I might employ an adhoc_ table for staging the data from an excel spreadsheet before I insert it into the database tables. This lets me separate the loading process, which is somewhat error prone, from the process of inserting the data into its destination using an INSERT. Of course, some adhoc_ objects might stick around. If they do, remove the adhoc_ pre-prefix.
The wip_ designator for Work In Progress tells other developers that the code isn't complete. Don't count on any wip_ code to work. wip_ should only be for development. wip_ objects shouldn't make their way into your production database.
I don’t really like the idea of deleting code. I always think that there’s going to be a good reason why I’m going to need it again. At the same time I like to keep my schema’s pretty clean and uncluttered by code or tables that aren’t used or even that might be harmful if used. While SourceSafe or other code management tools might be a good solution to keeping old versions around, if the object's name isn't changed it continues to appear to be useful even if it isn't. My solution is to rename any obsolete database objects with a prefix of “obs_”. This applies to tables, views, stored procedures, and UDFs. This has the advantage that the objects remain in the database and can be searched if desired but it’s obvious, at least to me, that “obs_” objects shouldn’t be used. Nor do they need to be included in upgrade scripts.
That's all I have to say about naming database objects. Explanation and ease of location are the two most important features of an object's name. I know that there are many naming conventions and that the most important thing is having one and following it. Even a mediocre convention that's followed is better than no convention at all.
Transact-SQL User-Defined Functions has been published! Take a look at it now!
Do you have an interesting stored procedure, user-defined-function,
or other sample code? If you'd like to share them please send
them in an email to:
coding-in-sql@NovickSoftware.com
and they might be published in this newsletter. I try and
respond to every request that I get.
Thanks,
Andy
Andrew Novick
New Tips:Loading SQL Profiler trace (.trc) files with fn_trace_gettrace |
Upcoming
|
|
Copyright © 2003-2008 Novick Software, Inc. | Terms of Use | Privacy Policy | Nice Things People Say| |