Darrell Norton's Blog [MVP]

Sponsors

The Lounge

Wicked Cool Jobs

News

  • Darrell Norton pic

    MVP logo

    View Darrell Norton's profile on LinkedIn

    Currently Reading:

    weewar.com

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Making database names friendly (or at least readable)

Most DBAs want to name each column something ridiculous (to developers, anyway) like A_PrdCdPct for a period code percentage amount. And the table is named AbcPrdCd; obviously that’s the Period Code table for the Abc application. Duh.

Recently I’ve come to the conclusion that database column and table names should be made “developer-friendly” in the database. If database access is solely through stored procs, it is easy to alias each column and table name, like this within the proc:

SELECT
I_PrdCdId as PeriodCodeID,
A_PrdCdPct as PeriodCodePercent
FROM AbcPrdCd as PeriodCode

If direct SQL access is needed, then views work well, although there may be a performance penalty when using views (although indexed views can help). Views are also useful when you want to transparently control user access to tables.

I usually don’t like to add additional layers of abstraction unless absolutely necessary, however I think the return for this small amount of work is big. I can’t count how many times the DBA group said, “Oh, we named that wrong so we changed it yesterday” as I sat there trying to figure out why stuff I checked in yesterday doesn’t work today. Yes communication would help, but better yet, let’s get rid of the whole problem! This would allow the DBAs to change column names to their hearts' content and our applications can remain blissfully unaware.


Posted Tue, May 18 2004 10:02 AM by Darrell Norton

[Advertisement]

Comments

Sanin wrote re: Making database names friendly (or at least readable)
on Tue, May 18 2004 9:08 AM
.
Dave wrote re: Making database names friendly (or at least readable)
on Tue, May 18 2004 2:41 PM
I couldn't agree more. I have had to work with a database where column names were like this: ATTRIB_A, ATTRIB_B, etc. When I asked what the hell those meant, I was told "Whatever you want - it's flexible". You can imagine my reaction.
Darrell wrote re: Making database names friendly (or at least readable)
on Tue, May 18 2004 3:42 PM
Dave - heh, I'll bet.

We've been doing it on our current project, and boy does it make a world of difference! We have to abide by idiotic naming conventions made back in the old unix days, so this is definitely a life saver. The only time we have to worry about the crummy physical database names is when we are actually writing stored procs.
Enjoy Every Sandwich wrote Take Outs for 19 May 2004
on Wed, May 19 2004 6:42 PM
Take Outs for 19 May 2004
dan-azoumi, abdoul-latif wrote re: Making database names friendly (or at least readable)
on Thu, Dec 23 2004 6:00 AM
i want to see all what you have on that name
Devlicio.us