I recently asked a colleague why they had included _TABLE at the end of all their database table names. They said it had been a standard at another orgainisation they had worked for. Other colleagues use V_ at the start of views.
Is this good practice?
When naming tables, you have two options – to use the singular for the table name or to use a plural. My suggestion would be to always go with names in the singular. If you're naming entities that represent real-world facts, you should use nouns. These are tables like employee, customer, city, and country.
A view is a database object that allows generating a logical subset of data from one or more tables. A table is a database object or an entity that stores the data of a database. The view depends on the table. The table is an independent data object.
So Which Should I Use: Singular or Plural? The correct answer is that there is no right or wrong when naming database tables — just be consistent from the start. The only wrong answer with database table names is to use a combination of plural and singular.
Consistency is the best approach. Adding a _TABLE or _VIEW at the end of an object name is overkill in my book, but if the database is designed that way, I wouldn't break from convention.
For your colleague to bring his naming convention from a previous organization into a new one without checking 'local' standards is bad practice.
Using v for view as a standard is particularly bad in my eyes because it prevents you from using one of the best ways of refactoring a database which is to rename the table and create a view with the old name that mimics the old structure so nothing breaks while you are making the change but you can start finding and fixing all the old references without having to fix all of them before the change is put to prod.
I'm also with akf on the idea that the real problem is taking naming conventions from some other organization and ignoring the naming conventions of the current organization. I'd stomp on this fast and insist that he change all the objects and associated code to whatever your standard is or this will continue to be a problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With