Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Views on views, guidance

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-10-27 : 15:35:55
Hi there,

I am working at this joint where they have plethora of views, that call other views , that call other views etc. what is a guiding principle that you would suggest on how to manage a spaghetti bowl of views other than reengineer their views. I mean it is scary. cryptic naming convention, stuff all over the place even some views existing in development servers. I mean what do you do short of walking away , back door.

I usually create one clean view per table and then a super view that joins a few tables based on a section of the overall tables carved out virtually by some logic. Any reading stuff you can point me to for good view design principles.

THanks

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2009-10-27 : 15:55:40
I would re-write the queries from scratch. It's not the answer you want to hear, but it's the only method that will save you headaches down the road.


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-10-27 : 16:48:16
Agreed. But your broader question depends on the purpose of the views. The typical benefits are:

1 - portability
you can move the underlying table(s) without any code changes other than re-defining the view.

2 - simplicity for end users
The consumers of the view do not need to be understand the complex model underlying the view

3 - security
You can expose only the data that you want the the view consumers to see.

I'm not a fan of views of views. That is usually a sign of a bad model and/or bad t-sql.

Be One with the Optimizer
TG
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-10-27 : 17:50:03
much appreciated! excellent points. simplicity is one of my biggest wants.

also leave the filter and WHERE clause on the procedures that call these views right? also make it so that all the VIEWS are LEFT JOIN? that is the design approach I am thinking.

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -