Naming Database Tables and Views

Viewed 34822

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?

7 Answers

It think akf answered the question well. And HLGEM makes a good point about refactoring.

However I would add this counterargument to having no prefix/suffix convention. In SQL Server (and probably other databases) you cannot have a table and a view with the same name in the same schema with the same owner. It is a common pattern to create a denormalized view for a table. If you haven't adopted a naming convention that distinguishes views from tables then you might end up with funny names for these views such as EMPLOYEE_DENORM instead of EMPLOYEE_V.

If the need arises for a refactoring such as HLGEM describes then your naming convention could allow for that. That way those views without the prefix or suffix are easily identified as "refactoring" views.

I think one of the best resources is always the AdventureWorks database from Microsoft. If you look at their views, they prefix them with a lowercase "v".

For example the table Employee has a view vEmployee.

Related