Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unless you fit the profile in the 2nd paragraph, I'd recommend staying away from views. They're deceptively enticing as a good way to abstract out underlying functionality. But the problem is that once developers start creating views, they tend to start creating different views for every possible combination of tables and fields, and it ends up an uncoordinated explosive mess. The DBA then has to maintain all of them because there's no way of telling which ones are actually used and which ones aren't, and developers end up just writing their own joins anyway because it's easier than wading through and figuring out which existing view to use.</p> <p>IMO, the only good reason to use views (and a fairly common one) is if the DBA needs to have freedom to modify the underlying tables without breaking existing client code. This is obviously only possible if that logic is on the DB side in a view or proc. If that applies to you, go ahead and use a view. Otherwise, I'd recommend a different way of looking at things.</p> <p>The power of a view is the abstraction it creates. But the fact is, the abstraction is used only by the client, not by the DB itself. Therefore I find it's better to put that abstraction on the client side. So rather than a view, just define a macro or string generator somewhere in the client code that will create your select statement for you. You can make these simple at first and progressively more intricate as your app progresses. That way you keep the abstration and reusability a view would offer, but avoid the explosion of views and the developer-DBA communication bottlenecks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload