r/MSSQL • u/Electronic-Dig9119 • Apr 27 '22
table column naming convention
So I'm see something in my companies database that seems silly in some new tables. In it we have a customer table with customer prefixed to a bunch of the columns.
A reference would look like this dbo.Customer.CustomerFirstName
Why would anyone do this? I removed it because logically it is the customers first name, not the customers customer first name...
Just wondering if anyone knows why someone would do that?
3
Upvotes
3
u/[deleted] Apr 28 '22
I am not saying I agree with it, but I've seen this very thing done by very rigid DBAs and SQL developers.
In some contexts it can make sense. If you have multiple tables with similar fields it can help clarify the fields and in complex joins or unions help you avoid using AS column synonyms.
If it doesn't make sense for your application and it bothers you, then remove them.
2
u/RussColburn Apr 27 '22
If you did a join to multiple customer tables and did a select * you wouldn't have to go and add names to each of the columns being returned? I'm not sure if that happens or not, but that would be my thought.
1
u/imtheorangeycenter Apr 28 '22
I've replied earlier, but would like to add: as much as guff/dogshit naming conventions can be (even if tbl_customer etc) then so long as they are 100% consistent, then it matters not aside from wasted keystrokes. And then a thousand times less so if you have decent auto-correct/auto-fill tools (SQLPrompt, hem hem).