Thursday, March 29, 2012

difference between table relations and foreign keys?

I've bought a book about ASP.NET with SQL Server 2000.
In one chapter, they talk about setting relations between tables, and in
another, about setting foreign keys.
But I can't understand the difference, as the purpose seems to be the same:
navigating from a parent table to a child one, and vice-versa.
Am I missing something?
Thanks!
HenriUnless you can show more detailed context, I think they are talking about
the exact same thing. A relationship is a bit more abstract; a foreign key
represents the implementation-specific way that a child row is connected to
a parent row.
--
http://www.aspfaq.com/
(Reverse address to reply.)
"Henri" <hmfireball@.hotmail.com> wrote in message
news:%23nSPik0TEHA.3828@.TK2MSFTNGP09.phx.gbl...
> I've bought a book about ASP.NET with SQL Server 2000.
> In one chapter, they talk about setting relations between tables, and in
> another, about setting foreign keys.
> But I can't understand the difference, as the purpose seems to be the
> same:
> navigating from a parent table to a child one, and vice-versa.
> Am I missing something?
> Thanks!
> Henri
>
>|||Actually, the first chapter is about the DataRelation class, and
DataTable.ChildRelations(String) and DataRow.GetChildRows(DataRelation).
The second chapter is about ForeignKeyConstraint Class
The only difference I see is that a foreign key allows to define cascade
update and delete rules.
Actually, ASP.NET permits to define many things like indexes, primary keys,
relations, etc. but I thought that this had to be done on SQL Server, not
from ASP.NET.
That's why I'm a bit lost :-)
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> a écrit dans le message de
news:ORWb%23o0TEHA.2416@.TK2MSFTNGP12.phx.gbl...
> Unless you can show more detailed context, I think they are talking about
> the exact same thing. A relationship is a bit more abstract; a foreign
key
> represents the implementation-specific way that a child row is connected
to
> a parent row.
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Henri" <hmfireball@.hotmail.com> wrote in message
> news:%23nSPik0TEHA.3828@.TK2MSFTNGP09.phx.gbl...
> > I've bought a book about ASP.NET with SQL Server 2000.
> > In one chapter, they talk about setting relations between tables, and in
> > another, about setting foreign keys.
> > But I can't understand the difference, as the purpose seems to be the
> > same:
> > navigating from a parent table to a child one, and vice-versa.
> > Am I missing something?
> > Thanks!
> > Henri
> >
> >
> >
>
>|||What you are reading about is Data Sets in ADO.Net. The
relations and constraints you define in a data set are
different and separate from relations and constraints in the
database. In ADO.Net, you can create something similar to a
database - tables (data tables), relationships (using the
DataRelation class), constraints (such as with the
ForeignKeyConstraint class). It's not the same thing as the
database you may be accessing for the data in the data sets.
For ADO.Net, you can find more information on how relations
and constraints work together, differently in .Net Framework
documentation. Check the remarks section of the definition
of the DataRelation class.
-Sue
On Fri, 11 Jun 2004 03:40:00 +0200, "Henri"
<hmfireball@.hotmail.com> wrote:
>Actually, the first chapter is about the DataRelation class, and
>DataTable.ChildRelations(String) and DataRow.GetChildRows(DataRelation).
>The second chapter is about ForeignKeyConstraint Class
>The only difference I see is that a foreign key allows to define cascade
>update and delete rules.
>Actually, ASP.NET permits to define many things like indexes, primary keys,
>relations, etc. but I thought that this had to be done on SQL Server, not
>from ASP.NET.
>That's why I'm a bit lost :-)
>
>"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> a écrit dans le message de
>news:ORWb%23o0TEHA.2416@.TK2MSFTNGP12.phx.gbl...
>> Unless you can show more detailed context, I think they are talking about
>> the exact same thing. A relationship is a bit more abstract; a foreign
>key
>> represents the implementation-specific way that a child row is connected
>to
>> a parent row.
>> --
>> http://www.aspfaq.com/
>> (Reverse address to reply.)
>>
>>
>> "Henri" <hmfireball@.hotmail.com> wrote in message
>> news:%23nSPik0TEHA.3828@.TK2MSFTNGP09.phx.gbl...
>> > I've bought a book about ASP.NET with SQL Server 2000.
>> > In one chapter, they talk about setting relations between tables, and in
>> > another, about setting foreign keys.
>> > But I can't understand the difference, as the purpose seems to be the
>> > same:
>> > navigating from a parent table to a child one, and vice-versa.
>> > Am I missing something?
>> > Thanks!
>> > Henri
>> >
>> >
>> >
>>
>|||Hi
Within ADO.Net, a Foreign Key Constaint is a subtype of the Data Relation. The FKC in ADO.Net behaves in a similar manner to a FKC within SQL Server, but it is a constraint on the Data Set, not the database, which can be an important consideration
A Data Relation has additonal functionality that is not provided by the FKC, ( I think one is providing the Child Rows in the Data Set to a particular Master row.) I suggest you have a look at the class definitions and examine the different methods and properties each suppiles|||Thanks for your help to both of you :-)
Just one last question:
If I define constraints and relations(diagrams) within SQL Server, can
ADO.NET retrieve them, so that I can use them without having to redefine
them when declaring the DataSet?
I'm currently checking the.NET doc and might find the answer by myself, but
if you know it, thank you for telling me :-)
Henri
"Henri" <hmfireball@.hotmail.com> a écrit dans le message de
news:%23nSPik0TEHA.3828@.TK2MSFTNGP09.phx.gbl...
> I've bought a book about ASP.NET with SQL Server 2000.
> In one chapter, they talk about setting relations between tables, and in
> another, about setting foreign keys.
> But I can't understand the difference, as the purpose seems to be the
same:
> navigating from a parent table to a child one, and vice-versa.
> Am I missing something?
> Thanks!
> Henri
>
>|||AFAIK, not by itself. I'd be surprised if there weren't utilities available out there to generate this stuff
for you, though.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Henri" <hmfireball@.hotmail.com> wrote in message news:uvGyEt5TEHA.3420@.TK2MSFTNGP09.phx.gbl...
> Thanks for your help to both of you :-)
> Just one last question:
> If I define constraints and relations(diagrams) within SQL Server, can
> ADO.NET retrieve them, so that I can use them without having to redefine
> them when declaring the DataSet?
> I'm currently checking the.NET doc and might find the answer by myself, but
> if you know it, thank you for telling me :-)
> Henri
> "Henri" <hmfireball@.hotmail.com> a écrit dans le message de
> news:%23nSPik0TEHA.3828@.TK2MSFTNGP09.phx.gbl...
> > I've bought a book about ASP.NET with SQL Server 2000.
> > In one chapter, they talk about setting relations between tables, and in
> > another, about setting foreign keys.
> > But I can't understand the difference, as the purpose seems to be the
> same:
> > navigating from a parent table to a child one, and vice-versa.
> > Am I missing something?
> > Thanks!
> > Henri
> >
> >
> >
> >
>
>|||Thanks :)
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> a écrit
dans le message de news:eljMa15TEHA.1012@.TK2MSFTNGP09.phx.gbl...
> AFAIK, not by itself. I'd be surprised if there weren't utilities
available out there to generate this stuff
> for you, though.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Henri" <hmfireball@.hotmail.com> wrote in message
news:uvGyEt5TEHA.3420@.TK2MSFTNGP09.phx.gbl...
> > Thanks for your help to both of you :-)
> > Just one last question:
> > If I define constraints and relations(diagrams) within SQL Server, can
> > ADO.NET retrieve them, so that I can use them without having to redefine
> > them when declaring the DataSet?
> > I'm currently checking the.NET doc and might find the answer by myself,
but
> > if you know it, thank you for telling me :-)
> > Henri
> >
> > "Henri" <hmfireball@.hotmail.com> a écrit dans le message de
> > news:%23nSPik0TEHA.3828@.TK2MSFTNGP09.phx.gbl...
> > > I've bought a book about ASP.NET with SQL Server 2000.
> > > In one chapter, they talk about setting relations between tables, and
in
> > > another, about setting foreign keys.
> > > But I can't understand the difference, as the purpose seems to be the
> > same:
> > > navigating from a parent table to a child one, and vice-versa.
> > > Am I missing something?
> > > Thanks!
> > > Henri
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>

No comments:

Post a Comment