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 messag
e 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...
>
>|||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 messa
ge de
>news:ORWb%23o0TEHA.2416@.TK2MSFTNGP12.phx.gbl...
>key
>to
>|||Hi,
Within ADO.Net, a Foreign Key Constaint is a subtype of the Data Relation. T
he FKC in ADO.Net behaves in a similar manner to a FKC within SQL Server, bu
t it is a constraint on the Data Set, not the database, which can be an impo
rtant 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 M
aster row.) I suggest you have a look at the class definitions and examine t
he different methods and pr
operties each suppiles

No comments:

Post a Comment