Re: GetParentRow(s) or GetChildRows?

From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 02/02/05


Date: Wed, 2 Feb 2005 09:43:50 -0600

Ben,
For a 1 to Many relationship it definitely makes a difference.

Consider you have 2 tables: Orders & Order Details.

Which table would you expect to be the Parent?

Which table would you expect to be the Child?

For a Many to Many relationship it physically doesn't make a difference,
however it may logically make a difference.

The following thread has an example of creating 2 tables that have a Many to
Many relationship & use of GetParentRows. Hopefully there is enough there to
give you ideas...

http://groups-beta.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/29cf283cf5a273c2/5c2f4a68079a57a8?q=Adding+a+column+to+a+dataset+group:microsoft.public.dotnet.languages.vb&_done=%2Fgroups%3Fas_q%3DAdding+a+column+to+a+dataset%26num%3D10%26scoring%3Dr%26hl%3Den%26ie%3DUTF-8%26as_epq%3D%26as_oq%3D%26as_eq%3D%26as_ugroup%3Dmicrosoft.public.dotnet.languages.vb%26as_usubject%3D%26as_uauthors%3D%26lr%3D%26as_drrb%3Dq%26as_qdr%3D%26as_mind%3D1%26as_minm%3D1%26as_miny%3D1981%26as_maxd%3D2%26as_maxm%3D2%26as_maxy%3D2005%26safe%3Doff%26&_doneTitle=Back+to+Search&&d#5c2f4a68079a57a8

If the link is broke, search groups.google.com for "Adding a column to a
dataset" from about 24 June 2004 in the microsoft.public.dotnet.languages.vb
newsgroup.

Hope this helps
Jay

"Ben R." <BenR@discussions.microsoft.com> wrote in message
news:B3A9D2D5-E54C-4702-8A27-1EE28B7E6D92@microsoft.com...
> Thanks for your reply, Jay. I think I'll grab a copy of that book. From
> what
> I see, this is the definition of the "add" method for adding a new
> datarelation:
>
> Creates a DataRelation with a specified parent and child column, and adds
> it
> to the collection.
>
> Supported by the .NET Compact Framework.
>
> [Visual Basic] Overloads Public Overridable Function Add(DataColumn,
> DataColumn) As DataRelation
> [C#] public virtual DataRelation Add(DataColumn, DataColumn);
>
> It looks like the first column passed in will serve as the parent and the
> second will serve as the child. Is this accurate? If so, does it make a
> difference which one will be parent and which will be child? I was under
> the
> impression that the child references data in the parent, but I could be
> mistaken. I don't see why it should matter if you use GetChildRows or
> GetParentRows becausefi you've got a starting point (a datarow) and a
> direction to go in (a datarelation), there's really no ambiguity, so why
> do
> you have to chose between these two choices?
>
> -Ben
>
> "Jay B. Harlow [MVP - Outlook]" wrote:
>
>> Ben,
>> The parent & child is defined when you define the DataRelation object
>> either
>> in code or via an XSD.
>>
>> All three functions expect a DataRelation (either name or actual object)
>> to
>> determine which relationship to resolve.
>>
>> For a complete explanation of advanced features of Datasets, such as
>> parent
>> rows & child rows, I would strongly recommend you read David Sceppa's
>> book
>> "Microsoft ADO.NET - Core Reference" from MS Press. As it is a good
>> tutorial
>> on ADO.NET as well as a good desk reference once you know ADO.NET.
>>
>> Hope this helps
>> Jay
>>
>> "Ben R." <BenR@discussions.microsoft.com> wrote in message
>> news:C120D191-E213-4D72-B903-C5F4A3300A50@microsoft.com...
>> > Could someone fill me in on the difference between the following three
>> > DataRow methods:
>> >
>> > GetParentRow
>> > GetParentRows
>> > GetChildRows
>> >
>> > I'm guessing the difference between the first two is that one returns
>> > an
>> > array while the other returns a single Row, which leads me to wonder,
>> > what
>> > would happen if this option were used but there were more than one
>> > parent
>> > row. On that note, in a relationship, what defines one row as a parent
>> > and
>> > one as a child? Is it that multiple child fields can refer to a single
>> > parent
>> > field and from this, the engine somehow deduces which side is the child
>> > and
>> > which is the parent? From what I see above, it's possible for a table
>> > to
>> > have
>> > multiple parents. How would this work? When you create a relation
>> > between
>> > tables in a dataset, if you don't specify which side is which, what
>> > rules
>> > are
>> > used to decide?
>> >
>> > Thanks...
>>
>>
>>



Relevant Pages

  • How to sort a DataGrid bound to a DataRelation?
    ... DataRelation defining the parent-child relationship between them. ... form, there is a DropDownList ComboBox bound to the parent table, ... rows from the child table. ... I can't use a DataView because ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Re: GetParentRow(s) or GetChildRows?
    ... Thanks for your reply, Jay. ... Creates a DataRelation with a specified parent and child column, ...
    (microsoft.public.dotnet.general)
  • Re: DataRelations and DataGrids
    ... Create a DataRelation LookupToMain. ... > a DataRelation between your parent tables and child tables and then use ... > relationships may return multiple rows, you must include the reference ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: DataRelations and DataGrids
    ... Yes you can use a DataRelation for this purpose, ... A parent table may be referenced in an expression by prepending the ... A column in a child table may be referenced in an expression by ... you must include the reference ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Does the order of the update matter?
    ... such as like where I would have an 'Order' parent table and an 'Order ... Details' child table. ... The 'Order Details' also has a child table to it named ... The primary key in the Orders table is a guid. ...
    (microsoft.public.dotnet.framework.adonet)

Loading