DataRelations vs Joins

  • Thread starter Thread starter Phil Townsend
  • Start date Start date
P

Phil Townsend

I have seen a lot on ADO.NET data relations, but my jury is still out on
the benefits of coding a data relation vs. using a join in a stored
procedure. I know there is more overhead when using the join, since
there is more data in the result set, but how big of an issue is this,
especially when working with smaller databases?
 
Phil,

It depends on what your needs are. If you have a need for a
parent/child relationship in your UI (you have to display it as such), then
a DataRelation is the way to go, as the responsibility of handling that
related data is handled by the classes that handle data binding, and not by
you.

However, if you just need to display this in one place, and no need for
a parent/child display, (where the child records are shown independent of
the parent), then I would do the join on the server and return that.

Hope this helps.
 
Another consideration is whether or not the data will require the
ability to be modified and updated back into the database using the
Update() call on a DataAdapter - in that case a relation is also
recommended. If you want to code any update logic yourself, then the
JOIN can be used.

Note that the use of a JOIN does not eliminate the ability to do any
updates back into the database via an adapter, but it does make the
coding more challenging and you will need to include more control
columns in the JOIN itself.

-ken
 
Back
Top