CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Darrell Norton's Blog [MVP]

Fill in description here...

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.



Comments

Sanin said:

.
# May 18, 2004 9:08 AM

Dave said:

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.
# May 18, 2004 2:41 PM

Darrell said:

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.
# May 18, 2004 3:42 PM

Enjoy Every Sandwich said:

Take Outs for 19 May 2004
# May 19, 2004 6:42 PM

dan-azoumi, abdoul-latif said:

i want to see all what you have on that name
# December 23, 2004 6:00 AM
Check out Devlicio.us!

Our Sponsors