Stored Procedure Question

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

Hi,

I am trying to come up with a design on how to retrieve data from my db.
The db represents an order with multiple child tables which also have child
tables. I am wondering is better to create one complex select statement
with inner joins or break it up? Any sugesstions?

Thanks
 
With very few exceptions it's better to pull over the data in a dataset with
a datatable representing each respecitve table you'd reference in the query.
At that point you could use a Datarelation
http://www.knowdotnet.com/articles/datarelation.html to join the tables and
do your thing. This would reduce pulling over redundant data and will make
your update scenarios much much easier. There are exceptions but for the
most part, pulling over the pieces and connecting them is going to be a much
cleaner approach.

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
 
So, your suggestion is to not have a complex select statement but rather
multiple queries and then piece it together? What about using a typed
dataset which already has the relations?

Thanks
 
Yes... avoid joins like the plague unless you can't help it. If you have to
do an update on that data in particular, it will be a nightmare using the
standard methodology of dataAdapter.Update

As far as the typed dataset, yes, that's essentially the same thing but
better if you know all of the fields at design time. Doing it dynamically
allows for some ambiguity, but using STD's gives you intellisense, better
performance and ease of use. Either way is a winner here.

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
 
Back
Top