When to use database views and when not?

后端 未结 8 970
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 19:31

This question is about database views, not materialized-views.

Pros:

  • Query simplification.
  • Avoid repeat the same joins on mul
8条回答
  •  既然无缘
    2020-12-13 19:46

    Now that SQL Server has common table expressions I find myself creating fewer views. When I do create a view it's usually for a normalized hierarchy that can be used in many queries not something that replaces one query.

    For example Region, Market, and City may be three normalized tables (snowflake). 90% of my queries need this data, so I'll create a view. The view never replaces a single query but makes all the other queries simple and DRY.

提交回复
热议问题