Hi,

Creating a DataRelation among two tables seems to be pretty simple
(according to ADO.NET Core Reference). However, I'm not sure of the best
time to create it. Is it better to create the DataRelation between the
tables after the tables have been filled, or is it better to create
ForeignKeyConstraints when creating the columns of each table?

Roshawn

Re: Creating a DataRelation by Miha

Miha
Fri Jul 23 09:16:22 CDT 2004

Hi,

"Roshawn" <udrago@bellsouth.net> wrote in message
news:eq1984LcEHA.3716@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> Creating a DataRelation among two tables seems to be pretty simple
> (according to ADO.NET Core Reference). However, I'm not sure of the best
> time to create it. Is it better to create the DataRelation between the
> tables after the tables have been filled, or is it better to create
> ForeignKeyConstraints when creating the columns of each table?

IMO the difference is the time you'll get an exception if reference can't be
enforced.
Doesn't matter otherwise.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com



Re: Creating a DataRelation by Jay

Jay
Fri Jul 23 09:31:07 CDT 2004

Roshawn,
As Miha suggests, it doesn't matter.

I normally create them based on the needs of my project. In one project I
create all the DataTables, then all the DataRelations, then I fill the
dataset. In another project I create the parent DataTables, then as I create
a child DataTable I create that child DataRelation.

Note I normally create the PrimaryKey constraints & the DataRelation
explicitly, allowing the framework create any ForeignKeyConstraints &
UniqueConstraints implicitly as a side effect of creating the
DataRelation...

For strongly typed data sets they will be created when you instantiate a new
strongly typed dataset.

Also you can use DataSet.EnforceConstraints to control if the constraint is
enforced while filling a dataset, thus controlling if an exception is thrown
or not.

> (according to ADO.NET Core Reference).
I was going to recommend Sceppa's book, but it sounds like you already have
it ;-)

Hope this helps
Jay

"Roshawn" <udrago@bellsouth.net> wrote in message
news:eq1984LcEHA.3716@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> Creating a DataRelation among two tables seems to be pretty simple
> (according to ADO.NET Core Reference). However, I'm not sure of the best
> time to create it. Is it better to create the DataRelation between the
> tables after the tables have been filled, or is it better to create
> ForeignKeyConstraints when creating the columns of each table?
>
> Roshawn
>
>



Re: Creating a DataRelation by William

William
Fri Jul 23 10:26:14 CDT 2004

Roshawn:

I definitely agree with Miha and Jay although there's one case that I'd
qualify my agreement a little. If you build the relations up front - before
any data is entered, then you'll be able to know for sure that you don't
have any non conforming data or that you won't raise an exception. So
ultimately it depends on your situation and when/how/if you chose to handle
your violating records.

I'm with you on Sceppa's book - it Rocks. But as a group, we all need to
talk Pablo and Angel into working with David and writing an update for
ADO.NET 2.0 or writing a new Book.

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
"Roshawn" <udrago@bellsouth.net> wrote in message
news:eq1984LcEHA.3716@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> Creating a DataRelation among two tables seems to be pretty simple
> (according to ADO.NET Core Reference). However, I'm not sure of the best
> time to create it. Is it better to create the DataRelation between the
> tables after the tables have been filled, or is it better to create
> ForeignKeyConstraints when creating the columns of each table?
>
> Roshawn
>
>



Re: Creating a DataRelation by Jay

Jay
Fri Jul 23 10:41:38 CDT 2004

William,
Yes the why is important, your reason is more why I create the relations
before I fill the dataset...

To a lesser extent it keeps the creation code in one place, separate from
the filling code.

Jay

"William Ryan eMVP" <dotnetguru@comcast.nospam.net> wrote in message
news:eyM0qiMcEHA.1356@TK2MSFTNGP09.phx.gbl...
> Roshawn:
>
> I definitely agree with Miha and Jay although there's one case that I'd
> qualify my agreement a little. If you build the relations up front -
before
> any data is entered, then you'll be able to know for sure that you don't
> have any non conforming data or that you won't raise an exception. So
> ultimately it depends on your situation and when/how/if you chose to
handle
> your violating records.
>
> I'm with you on Sceppa's book - it Rocks. But as a group, we all need to
> talk Pablo and Angel into working with David and writing an update for
> ADO.NET 2.0 or writing a new Book.
>
> --
>
> W.G. Ryan, eMVP
>
> Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
> Let Microsoft know!
> https://www.windowsembeddedeval.com/community/newsgroups
> "Roshawn" <udrago@bellsouth.net> wrote in message
> news:eq1984LcEHA.3716@TK2MSFTNGP11.phx.gbl...
> > Hi,
> >
> > Creating a DataRelation among two tables seems to be pretty simple
> > (according to ADO.NET Core Reference). However, I'm not sure of the
best
> > time to create it. Is it better to create the DataRelation between the
> > tables after the tables have been filled, or is it better to create
> > ForeignKeyConstraints when creating the columns of each table?
> >
> > Roshawn
> >
> >
>
>



Re: Creating a DataRelation by William

William
Sat Jul 24 21:50:03 CDT 2004

I definitely agreed/agree with you (as usual). However you didn't comment on
my plan to help me peer pressure the ADO.NET supermen to write a new book
;-)

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:%23m20SuMcEHA.2468@TK2MSFTNGP09.phx.gbl...
> William,
> Yes the why is important, your reason is more why I create the relations
> before I fill the dataset...
>
> To a lesser extent it keeps the creation code in one place, separate from
> the filling code.
>
> Jay
>
> "William Ryan eMVP" <dotnetguru@comcast.nospam.net> wrote in message
> news:eyM0qiMcEHA.1356@TK2MSFTNGP09.phx.gbl...
> > Roshawn:
> >
> > I definitely agree with Miha and Jay although there's one case that I'd
> > qualify my agreement a little. If you build the relations up front -
> before
> > any data is entered, then you'll be able to know for sure that you don't
> > have any non conforming data or that you won't raise an exception. So
> > ultimately it depends on your situation and when/how/if you chose to
> handle
> > your violating records.
> >
> > I'm with you on Sceppa's book - it Rocks. But as a group, we all need
to
> > talk Pablo and Angel into working with David and writing an update for
> > ADO.NET 2.0 or writing a new Book.
> >
> > --
> >
> > W.G. Ryan, eMVP
> >
> > Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
> > Let Microsoft know!
> > https://www.windowsembeddedeval.com/community/newsgroups
> > "Roshawn" <udrago@bellsouth.net> wrote in message
> > news:eq1984LcEHA.3716@TK2MSFTNGP11.phx.gbl...
> > > Hi,
> > >
> > > Creating a DataRelation among two tables seems to be pretty simple
> > > (according to ADO.NET Core Reference). However, I'm not sure of the
> best
> > > time to create it. Is it better to create the DataRelation between
the
> > > tables after the tables have been filled, or is it better to create
> > > ForeignKeyConstraints when creating the columns of each table?
> > >
> > > Roshawn
> > >
> > >
> >
> >
>
>