Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 20th, 2008, 08:56 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default Datase DataRelation

Hi,

I have a simple table structure like this:

tblCulture -------> tblModuleString <-------- tblModule
CultureId PK CultureId FK ModuleKey PK
                     ModuleKey FK

So I have a 1 to many relationship between tblCulture.CultureId and tblModuleString.CultureId and a 1 to many relationship between tblModule.ModuleKey and tblModuleString.ModuleKey

Up to now I had only used datasets with two tables but now I have three tables in the relationship.

I have been able to create a dataset that will take care of the 1 to many relationship between tblModule.ModuleKey and tblModuleString.ModuleKey but I am not sure how to create the other relationship with the tblCulture.CultureId.

I would appreciate if someone could shed some light.

Cheers

// Set dataset table names
dataSet.Tables[0].TableName = "Module";
dataSet.Tables[1].TableName = "ModuleString";
// Create a data relation between the Module (parents) and ModuleString (children)
DataColumn parentColumn = dataSet.Tables["Module"].Columns["ModuleKey"];

DataColumn childColumn = dataSet.Tables["ModuleString"].Columns["ModuleKey"];

DataRelation moduleToModuleString = new DataRelation("ModuleToModuleString", parentColumn, childColumn);

dataSet.Relations.Add(moduleToModuleString);
 
Old January 22nd, 2008, 01:27 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

Pallone:
It would help if you could define the "relationship" between a Culture and a Module. You have resolved the many-to-many relationship by using the junction table. According to ModuleStringTbl, you will be able to retrieve many cultureID and other culture information from the CultureTbl based on ModuleID and vice versa you will be able to retrieve many ModuleID and other Module Information from the ModuleTbl based on the ModuleID based on the CultureID associated with the ModuleID.

Hope this helps.

========================
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
 
Old January 23rd, 2008, 06:48 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 290
Thanks: 24
Thanked 0 Times in 0 Posts
Default

Hi peace95,

Thanks for you reply.

In fact the information I need to get is all in tblModuleString. But I need to create the relationship between tblCulture.CultureId and tblModuleString.CultureId.

Cheers
 
Old January 26th, 2008, 02:28 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

Pallone:

I am going to try a different approach to the same idea: The objective is to establish a relationship between ModuleTbl and the CultureTbl, right? So let's do just that:
  CultureTbl>--------<ModuleTbl
   CultureID ModuleID This is a many-to-many relationship that says: "For each and every CultureID consists of 1 or more ModuleID". The reverse is also true, "For each and every ModuleID is made up of one or more CultureID". However, Many-to-Many relationships MUST BE resolved....hence the Junction Table, which is your ModuleStringTbl, which you created, sits between the CultureTbl and the ModuleTbl:
  CultureTbl---------<ModuleStringTbl>--------ModuleTbl
  CultureID ModuleID,CultureID ModuleID
What the above relationship states: "For each CultureID may consists of 1 or more ModuleIDs" and "For each ModuleID may consists of 1 or more CultureID"

In the above example there also exists relationships between the CultureTbl.CultureID and ModuleString.CultureID: "For each and every ModuleString.CultureID there exists 1 and only 1 CultureTbl.CultureID"; This relationship defines the CultureTble.CultureID as the LookupTbl as in a dropdownlist box. Also important is that as an administrator new CultureID's are added on the the CuluteTbl. The same is true for the ModuleTbl.ModuleID and the ModuleStringTbl.ModuleID.

Hope this helps.

========================
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display 'Empty data' when fill datase cJeffreywang ASP.NET 2.0 Basics 2 August 28th, 2008 11:57 PM
Field not a DataColumn or DataRelation flashmanTom SQL Server 2005 0 January 30th, 2008 09:55 AM
Field not a DataColumn or DataRelation flashmanTom Visual Studio 2005 0 January 26th, 2008 02:50 PM
Reg: displaying datase in xml format asp.net 2.0 sadiashoiab ADO.NET 0 April 19th, 2007 03:17 PM
Chapter 14 TIO #1406 Object That Provides a DataSe dcollins BOOK: Beginning ASP.NET 2.0 and Databases 0 October 23rd, 2006 01:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.