When to use database views and when not?

FerranB picture FerranB · Mar 10, 2009 · Viewed 30.2k times · Source

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

Pros:

  • Query simplification.
  • Avoid repeat the same joins on multiples queries.
  • Avoid magic numbers.

Cons:

  • Hiding real queries (may be you are repeating joins).

What else?

Answer

Andy White picture Andy White · Mar 10, 2009

Pros: Allows you to change the underlying data structures without affecting the queries applications are using (as long as your view can hide the data structures)