5

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.

Timur Shtatland
  • 125
  • 2
  • 11

1 Answers1

7

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:

Erwin Brandstetter
  • 185,527
  • 28
  • 463
  • 633