Let us face it, in most companies that programmers work for, we end up doing database work. I do not agree with this since I think the DBA or BIA should handle database programming and we should stick to what we do best… coding. Would you want a DBA writing code? I think not. With that said, here are database naming standards that I use when in this situation. DBA’s might not agree with how database coders name databases; stored procedures, etc. but we need something.
Stored Procedure Naming Standard
With SQL Server 2005 and above, standards have changed a bit and have become more like the .NET standards. You can see this in how Microsoft names their stored procedures in their newer programs.
Naming Convention TableNameOrBusinessProcess_PredominantAction_<project, application, or logical segment>
I really do not like underscores in names, but since these could get long, it might be good to make them easier to read. In addition, prefixes are out. They are only used by the system stored procedures to be backward compatible.
Predominant Actions
- Select – returns multiple rows
- Get – Returns 1 row
- Update
- Delete
- Insert
- Extract
- Import
- Save – Combines insert/update
Of course, we can add more to these if you want. Here are a few examples,
- ClientLicense_Get
- RentalCar_Save
- RentalCar_Delete
- Vendors_Select
As you can see with “RentalCar”, if you put the action after the table name or business process, it is
much easier to find everything you can do with Rental Cars.
Project, Application, or Logical Segment
This is optional; separating the stored procedures by one of these areas can be helpful by just adding this to the end of the stored procedure. Here is an example,
- ClientLicense_Get_ClientAppliation
- ClientLicense_Get_ServerAppliation
Also, as you can see, for the first two segments, follow normal Pascal casing.
As with naming standards for code, this standard or your own needs to be enforced otherwise every developer will use their own and your database will be a lot harder to understand.
Please share your database naming standards by making a comment below.