473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

relationship tables and datarelations

niv
Hi,

I am unsure on how to retrieve data from tables 2 tables
that are related through a relationship table..

TableOne
--------
TableOneID
TableOneDesc

TableTwo
--------
TableTwoID
TableTwoDesc
TableOne_TableTwo_Relationship
------------------------------
TableOne_TableTwo_RelID
TableOneID
TableTwoID

I have related TableOne to TableOne_TableTwo_Relationship.
Then I have related TableTwo to
TableOne_TableTwo_Relationship.

I am unsure on how to traverse though the set
relationships to retrieve data. ie) I want to print out
all TableTwoDesc that have been related to a specific
TableOneID.

Thanks for your help,

niv
Nov 15 '05 #1
4 5563
niv
I have added the DataRelation objects that I have created
below.
DataRelation TableOneToRelTable = dsTest.Relations.Add
("T1ToRel", TableOne.Columns["TableOneID"],
TableOne_TableTwo_Relationship.Columns["TableOneID"]);

DataRelation TableTwoToRelTable = dsTest.Relations.Add
("T2ToRel",TableTwo.Columns["TableTwoID"],
TableOne_TableTwo_Relationship.Columns["TableTwoID"]);

-----Original Message-----
Hi,

I am unsure on how to retrieve data from tables 2 tables
that are related through a relationship table..

TableOne
--------
TableOneID
TableOneDesc

TableTwo
--------
TableTwoID
TableTwoDesc
TableOne_TableTwo_Relationship
------------------------------
TableOne_TableTwo_RelID
TableOneID
TableTwoID

I have related TableOne to TableOne_TableTwo_Relationship.
Then I have related TableTwo to
TableOne_TableTwo_Relationship.

I am unsure on how to traverse though the set
relationships to retrieve data. ie) I want to print out
all TableTwoDesc that have been related to a specific
TableOneID.

Thanks for your help,

niv
.

Nov 15 '05 #2
niv
I have to do it this way because I am working with 3
DataTables.

What do you mean by use a SQL statement?
how? When retrieving the DataSet?
Thanks,
niv
-----Original Message-----
I am not sure what you mean by "traversing through the set relationships toretrieve data". Why can't you use just a SQL select statement?
SELECT t2.TableTwoDesc
FROM TableOne t1 INNER JOIN TableOne_TableTwo_Relationship t12ON t1.TableOneID = t12.TableOneID
INNER JOIN TableTwo t2
ON t12.TableTwoID = t2.TableTwoID
WHERE t1.TableOneID = myID

Eliyahu

"niv" <ni*@hotmail.com> wrote in message
news:0d****************************@phx.gbl...
Hi,

I am unsure on how to retrieve data from tables 2 tables
that are related through a relationship table..

TableOne
--------
TableOneID
TableOneDesc

TableTwo
--------
TableTwoID
TableTwoDesc
TableOne_TableTwo_Relationship
------------------------------
TableOne_TableTwo_RelID
TableOneID
TableTwoID

I have related TableOne to TableOne_TableTwo_Relationship. Then I have related TableTwo to
TableOne_TableTwo_Relationship.

I am unsure on how to traverse though the set
relationships to retrieve data. ie) I want to print out
all TableTwoDesc that have been related to a specific
TableOneID.

Thanks for your help,

niv

.

Nov 15 '05 #3
I meant making SQL requests against tables in the database using appropriate
DB access components, like DataAdapter, DbCommand (Ole or Sql) for
populating the dataset.

As I see now, you mean something else. You already have your dataset with 3
tables inside and you want to run your requests against the tables in the
dataset as opposed to the ones in the database. If you insist on this model,
I can't help you much, I don't have any practical experience in selecting
required data from the related tables in the dataset. But, it looks to me,
you could charge your database with running selects, with sql it's easy and
straightforward. Just one data access operation with the select will
replaces many lines on code you might have to write otherwise. Also, you
wouldn't need your DataRelation object.

OK, I understand that you might still have good reasons to follow your way.

Eliyahu

"niv" <ni*@hotmail.com> wrote in message
news:00****************************@phx.gbl...
I have to do it this way because I am working with 3
DataTables.

What do you mean by use a SQL statement?
how? When retrieving the DataSet?
Thanks,
niv
-----Original Message-----
I am not sure what you mean by "traversing through the

set relationships to
retrieve data". Why can't you use just a SQL select

statement?

SELECT t2.TableTwoDesc
FROM TableOne t1 INNER JOIN

TableOne_TableTwo_Relationship t12
ON t1.TableOneID = t12.TableOneID
INNER JOIN TableTwo t2
ON t12.TableTwoID = t2.TableTwoID
WHERE t1.TableOneID = myID

Eliyahu

"niv" <ni*@hotmail.com> wrote in message
news:0d****************************@phx.gbl...
Hi,

I am unsure on how to retrieve data from tables 2 tables
that are related through a relationship table..

TableOne
--------
TableOneID
TableOneDesc

TableTwo
--------
TableTwoID
TableTwoDesc
TableOne_TableTwo_Relationship
------------------------------
TableOne_TableTwo_RelID
TableOneID
TableTwoID

I have related TableOne to TableOne_TableTwo_Relationship. Then I have related TableTwo to
TableOne_TableTwo_Relationship.

I am unsure on how to traverse though the set
relationships to retrieve data. ie) I want to print out
all TableTwoDesc that have been related to a specific
TableOneID.

Thanks for your help,

niv

.

Nov 15 '05 #4
I have recently found myself in the same boat because I am populating a
DataSet via an XML file, not from a database. I am currently looking at a
number of methods to filter and sort the data.

One is the Select method of the DataTable object. This seems to provide an
SQL type selection syntax. Another is the GetChildRows method of the
DataRow object which doesn't appear to offer any type of sort capabilities,
if that is important to you. And lastly I'm looking at manually iterating
the rows of the tables with a foreach loop in search of matching child rows.

As of yet I don't have any clue as to the performance differences of any of
these methods. Fortunately for me my DataSet simply has two tables with one
relationship and there will be very few rows in either table. I doubt that
performance will be an issue for me so I'll most likely choose the method
that produces the cleanest code unless I can find direction otherwise.

HTH
--
Bobby C. Jones
code.AcadX.com

"niv" <ni*@hotmail.com> wrote in message
news:0d****************************@phx.gbl...
Hi,

I am unsure on how to retrieve data from tables 2 tables
that are related through a relationship table..

TableOne
--------
TableOneID
TableOneDesc

TableTwo
--------
TableTwoID
TableTwoDesc
TableOne_TableTwo_Relationship
------------------------------
TableOne_TableTwo_RelID
TableOneID
TableTwoID

I have related TableOne to TableOne_TableTwo_Relationship.
Then I have related TableTwo to
TableOne_TableTwo_Relationship.

I am unsure on how to traverse though the set
relationships to retrieve data. ie) I want to print out
all TableTwoDesc that have been related to a specific
TableOneID.

Thanks for your help,

niv

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gt394 | last post by:
tbl_Quote PK QuoteNo tbl_QuoteDetails - Junction table between tbl_Quote and tbl_Product tbl_Product PK ProductID tbl_Thickness PK ThicknessID tbl_PanelType PK PanelID...
4
by: Steve Klett | last post by:
(I posted this in ADO group, but I think this group will be better) Hi- I need to develop an FAQ section for our website. We would like to break up the FAQ by products, then categories with...
0
by: George Durzi | last post by:
I have a DataSet with 3 tables, and two DataRelations dsSubs.Tables.TableName = "Subscriptions" dsSubs.Tables.TableName = "AccountManagers" dsSubs.Relations.Add "AccountManagers_Subscriptions",...
3
by: I am Sam | last post by:
I can relate two tables rather easily using the following code: dsClub.Relations.Add("Section_Data", dsClub.Tables.Columns, dsClub.Tables.Columns); Which connects the "Section" table to the...
2
by: cspowart | last post by:
Consider first, table "A" : Plate Make Model ===================== ABC123 Ford F150 XYZ789 Dodge 1500 IJK444 Chev Silverado Then consider, table "B";
0
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
I'm working in Visual Studio 2005 Team Edition for Software Developers. I have 3 tables defined in the DataSet Designer, and a DataRelation between each table. The user sees a each of these...
1
by: learning_codes | last post by:
Hi, I need your help. I created a relationship on four tables. It works nicely. Each table has a code type. Group A Table --- Field Name: Code Type "T" Group B Table
1
by: Ivan | last post by:
Hi I created a databse system but i have a problem figuring out how to create some tables / relationships.... The part of the systems that i am having problems with is the following i have a...
6
by: BD | last post by:
Hi, all. I need to enforce a one-to-many relationship on 2 tables, with a join table. Say the join table contains account information. It has cust_no and acct_no. Both cust_no and acct_no are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.