About My Query Style

After our DBA laughed at me once again for the way I write queries, I feel the need to make a general statement about this.  It’s not a defense, because I don’t feel like that’s necessary, but I wanted to clarify why I write them the way that I do, because die-hard SQL folks find them hard to look at.  

The thing I’m talking about here is always using the whole names of tables and columns instead of subbing/aliasing everything.

The first reason is because I’m not writing these for SQL brainiacs.  I assume that a lot of people who come across them will not be accustomed to SQL query writing and while leaving all the long names of everything might be a bit dizzying, at least you can tell what you’re looking at during the moment you’re looking at it, instead of having to go look up the references somewhere else in the query.

Another reason is that the Project Server Reporting database has a specific structure which is not going to change.  If I need to steal a piece of one query and put it in another one, I don’t have to make sure that my aliases are all the same or wonder if there’s going to be issues with that.

And of course, one reason is that it’s what I started off looking at (stealing the queries in the SDKs and sample reports) so it’s how I learned.

Last but not least, I’m a very fast typer.  I can type MSP_EPMProject_UserView.ProjectName in about one second so I don’t find long words to be any kind of road block, so why not be specific?  My only real issue with it is that I find myself trying to randomly capitalize letters in the middle of compound words all the time.  So I find myself writing things like LifeTime and FireWorks and BaseBall…etc and it’s kind of embarrassing.

So, that will wrap up today’s Blog_Entry_Lite[TM]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s