Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

This question already has an answer here:

We have few join-heavy queries to our SQL Server 2008 database and in an attempt to optimize them I thought of having a view that would produce this

OrderID     Number    Traveller
1           102       1015;John Doe|1016;Jon Appleseed

out of

OrderID     Number
1           102


TravellerID    OrderID    FullName
1015           1          John Doe
1016           1          Jon Appleseed

My question is: how bad is it from a DBA's standpoint? On the one hand, it gets the job done, but this solution really bothers the purist side of me.

share|improve this question
    
Do you plan to further use these views by joining them to other tables (or - the horror - to similar views) using these columns? –  ypercube Jun 14 '13 at 11:46
    
How heavy are your join queries? Do you have proper indexing/statistics? If so you should have no trouble with the joins, as opposed to the non-relational-like view –  user16484 Jun 14 '13 at 12:04
    
What will the results be used for? If it's for some type of report, perhaps what you need to do is cache the result and invalidate when the data source changes. –  Jon Seigel Jun 14 '13 at 14:52
add comment

marked as duplicate by ypercube, dezso, StanleyJohns, RolandoMySQLDBA, Mark Storey-Smith Jun 15 '13 at 2:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

It depends on how the views are going to be queried. If the purpose is to do something like

SELECT OrderID from dbo.vw_Orders WHERE Traveler like '%Jon Appleseed%' 

then you should NOT do this. If you are just using the view to return a list that will be parsed by your application, then it may not be so bad.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.