473,394 Members | 2,160 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,394 software developers and data experts.

Data Binding with Relationships

Hi everyone,

I am writing some C# code using Visual Studio 2003 Enterprise Architech to
allow addresses in a database, to be accessesd so that the data can be
validated. I have 4 basic tables on the SQL Server 2000 (with SP3a).

These tables are named Addresses, StreetsInTowns, Streets and Towns. The
Streets table has a Primary Key named StreetID and the Towns table has a
primary key TownID. Both tables has a column named Name for the Street Name
or Town Name, we have some other info but for this we can ignore.

The Addresses Table contains the things like the Building Number and
Building Name and has 2 columns named StreetID and TownID that are related to
The StreetID column of the Streets table and the TownID column of the Towns
table. In our last table StreetsInTowns we have a Primary key StreetTownID
and 2 columns named StreetID and TownID, StreetID is related to StreetID of
the Streets table and the TownID of the Towns table. This table is used to
tell us what Towns has what Streets or what Streets are in what Town, example
- we could have a High Street in Anytown and Bigtown. Now what I am trying to
do is have 2 comboBoxes, 1 for Street and 1 for Town on a Windows Form, and
on a Web Form for the Web System, and at runtime the Street comboBox loads
all the Streets and the Town comboBox loads all the Towns. When say the
Street is changed I want the Town comboBox to load all the Towns that the
Street is associated with. And if the Town is changed I want all the Streets
in that town to load. I am looking for a simple way of doing, I have tried
working with views but it's too complicated for my head. I know their is a
simple way to achive what I want but don't really know how, I have read about
reversing the DataRelations Keys but this sounds like it could have problems
long term. I am working with a DataSet where the tables are all related. I
would like to link all this without too much coding.

Cheers in advance guys. If I have not been clear let me know!!!!
Nov 16 '05 #1
2 1362
Paul,

Personally, I think the data model is incorrect. Even though two
streets in two towns might have the same name, they are different entities,
and (I believe) should be treated as such.

You might be saving some DB space, but you are increasing the complexity
WAY too much using this design. You don't get much in the way of ease of
use with this model.

Basically, I would have the street have a FK to the town it is a part
of, and if there are two streets with the same name, then they have two
entries in the database.

If you do it this way, then when showing the streets for a particular
down, you just have to create the relation between the street and town, and
call the GetChildRows method on the record that you are looking at in the
town table.

Better yet, if you bind the streets list to the relation, and not the
child table, then the binding mechanism will do it for you, automatically,
depending on the town selected.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dr. Paul Caesar - CoullByte (UK) Limited"
<Dr****************************@discussions.micros oft.com> wrote in message
news:F0**********************************@microsof t.com...
Hi everyone,

I am writing some C# code using Visual Studio 2003 Enterprise Architech to
allow addresses in a database, to be accessesd so that the data can be
validated. I have 4 basic tables on the SQL Server 2000 (with SP3a).

These tables are named Addresses, StreetsInTowns, Streets and Towns. The
Streets table has a Primary Key named StreetID and the Towns table has a
primary key TownID. Both tables has a column named Name for the Street
Name
or Town Name, we have some other info but for this we can ignore.

The Addresses Table contains the things like the Building Number and
Building Name and has 2 columns named StreetID and TownID that are related
to
The StreetID column of the Streets table and the TownID column of the
Towns
table. In our last table StreetsInTowns we have a Primary key StreetTownID
and 2 columns named StreetID and TownID, StreetID is related to StreetID
of
the Streets table and the TownID of the Towns table. This table is used to
tell us what Towns has what Streets or what Streets are in what Town,
example
- we could have a High Street in Anytown and Bigtown. Now what I am trying
to
do is have 2 comboBoxes, 1 for Street and 1 for Town on a Windows Form,
and
on a Web Form for the Web System, and at runtime the Street comboBox loads
all the Streets and the Town comboBox loads all the Towns. When say the
Street is changed I want the Town comboBox to load all the Towns that the
Street is associated with. And if the Town is changed I want all the
Streets
in that town to load. I am looking for a simple way of doing, I have tried
working with views but it's too complicated for my head. I know their is a
simple way to achive what I want but don't really know how, I have read
about
reversing the DataRelations Keys but this sounds like it could have
problems
long term. I am working with a DataSet where the tables are all related. I
would like to link all this without too much coding.

Cheers in advance guys. If I have not been clear let me know!!!!

Nov 16 '05 #2
Nicholas,

Thanks for your thoughts on my data modal. I am redesigning it as some where
in your thoughts I picked up on a possible problem in the future with the
data modal, that being what would happen if a Street was renamed!! So yeah my
data modal is incorrect so thanks for your input.
Dr. Paul Caesar
CoullByte (UK) Limited
Nov 16 '05 #3

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

Similar topics

1
by: Chris Ashley | last post by:
I used the data form wizard and set up my relationships between tables... how do I make the foreign key a dropdown in the datagrid so it displays something meaningful rather than the foreign key...
2
by: yuanh23 | last post by:
Hi, I have 3 talbes "customers","orders","details". i wanna to use 3 datagrids to show those tables. and when the selected row in parent talbe changes, the selected row in child table changes...
3
by: pemigh | last post by:
A while back I imported tables to a new database via Files-->Get External Data --> Import... All was well for several months, and then the database started behaving badly in a couple of ways,...
17
by: deko | last post by:
Is there a Pattern or best Practice for getting relational data out of a database and into an object? The object in question has public properties that look like this: _stringName _ArrayList...
0
by: Michael | last post by:
Okay, maybe I am missing something. I created a dataset through VS2005 data manager. The set includes tables with child relationships. The tables and the relationships are included in the dataset....
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
5
by: Kosmos | last post by:
Hey :) hopefully someone can help me with this...I decided to take on the task of programming an access database for my legal co-op/internship...I'm studying law and music production on the...
16
by: Wayne | last post by:
I have an Access 2003 data file that has now corrupted twice in a week. The database is extremely simple with one main data table and a few lookup tables. The lookup tables are linked to the main...
6
by: Wesley Peace | last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having with visual studio 2008. I've created a series of forms with controls to access a Access database tables. The...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.