S
Somebody
To simplify the question, I create 2 tables in SQL.
Table_1 has columns: ColumnA (PK), ColumnB and Type.
Table_2 has columns: A (PK) and Description
Now, I want to set things up so that Table_1.Type is of type Table_2.A.
1) I guess in SQL lingo, what I'm trying to say is that Table_1.Type is a FK
to Table_2.A. Is that correct terminology? Is that backwards? It appears to
me to be correct.
2) So I create the relationship in SQL and SQL names it FK_Table_1_Table_2.
In the Database diagram, the key icon is on the Table_2 side and I get the
little infinity sign on the Table_1 side. Is that correct or should it be
the other way around? From what I gather from looking online, the key icon
should be on the table with the PK and the infinity sign should be on the
other table, right?
3) OK, assuming that #1 & #2 are correct
... I then add the datasource to
my project and import the TABLES. Ado.net generates all the wrapper classes,
schemas, etc.
Now my confusion occurs...
FK_Table_1_Table_2 is defined as:
this.relationFK_Table_1_Table_2 = new
global::System.Data.DataRelation("FK_Table_1_Table_2",
new global::System.Data.DataColumn[]
{
this.tableTable_2.AColumn
},
new global::System.Data.DataColumn[]
{
this.tableTable_1.TypeColumn
},
false);
So, as you can see, the wizard added Table_2.A first, and then Table_1.Type.
According to MSDN, that makes Table_2.A the PARENT COLUMN and Table_1.Type
the CHILD COLUMN.
Isn't that backwards? Cuz if I have a Table_1 row and want to get its type
description (Table_2) I need to do:
DataRow[] r = row1.GetParentRows(ds.Relations["FK_Table_1_Table_2"]);
Or do I have the parent/child terms backwards in my head?
Table_1 has columns: ColumnA (PK), ColumnB and Type.
Table_2 has columns: A (PK) and Description
Now, I want to set things up so that Table_1.Type is of type Table_2.A.
1) I guess in SQL lingo, what I'm trying to say is that Table_1.Type is a FK
to Table_2.A. Is that correct terminology? Is that backwards? It appears to
me to be correct.
2) So I create the relationship in SQL and SQL names it FK_Table_1_Table_2.
In the Database diagram, the key icon is on the Table_2 side and I get the
little infinity sign on the Table_1 side. Is that correct or should it be
the other way around? From what I gather from looking online, the key icon
should be on the table with the PK and the infinity sign should be on the
other table, right?
3) OK, assuming that #1 & #2 are correct
![Smile :) :)](/styles/default/custom/smilies/smile.gif)
my project and import the TABLES. Ado.net generates all the wrapper classes,
schemas, etc.
Now my confusion occurs...
FK_Table_1_Table_2 is defined as:
this.relationFK_Table_1_Table_2 = new
global::System.Data.DataRelation("FK_Table_1_Table_2",
new global::System.Data.DataColumn[]
{
this.tableTable_2.AColumn
},
new global::System.Data.DataColumn[]
{
this.tableTable_1.TypeColumn
},
false);
So, as you can see, the wizard added Table_2.A first, and then Table_1.Type.
According to MSDN, that makes Table_2.A the PARENT COLUMN and Table_1.Type
the CHILD COLUMN.
Isn't that backwards? Cuz if I have a Table_1 row and want to get its type
description (Table_2) I need to do:
DataRow[] r = row1.GetParentRows(ds.Relations["FK_Table_1_Table_2"]);
Or do I have the parent/child terms backwards in my head?