Naming conventions for views and materialized views: "*_v", "v_*", "*_mv", "mv_*" or none?

All we need is an easy explanation of the problem, so here it is.

My view stores quality metrics for various gizmos1 in the database. Today I designed it to be a view. In a few years, as we produce more gizmos, it may need to be changed to a materialized view.

I was thinking of naming the view either of these 3 ways:
gizmo_quality_metrics
gizmo_quality_metrics_v
v_gizmo_quality_metrics

Which one should I choose?

This may need to be renamed (or not) a few years later, when switching it to a materialized view:
gizmo_quality_metrics
gizmo_quality_metrics_mv
mv_gizmo_quality_metrics

From the way I worded the question, you get the idea that I favor keeping the same name (gizmo_quality_metrics), which is based on the data, and disregard the implementation (thus, no prefixes and extensions). However, I have seen all of the above naming conventions in practice, and I am wondering what is the most maintainable one for the long term.


1 I am simplifying – of course, they are not gizmos. They are actually deoxyribonucleic acid (DNA) molecules, if you really want to know. But this is irrelevant.


[EDIT, Mar 18, 2022]

Related question (thanks to a_horse_with_no_name for mentioning it!):
Is adding the ‘tbl’ prefix to table names really a problem?
Note that I do not link to any one particular answer in that literal wall of answers, from high to low rep users. It is instructive to read a few, though.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Naming conventions are largely a question of taste and style.

The one important thing is to stay consistent. An inconsistent naming convention is often worse than none at all. To give my opinion: don’t add any prefix or suffix. Especially since you intend to switch later.

And always stick to legal, lower-case names. So you never have to double-quote. See:

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply