Parent-Child Relations in two Comboboxes Once more (approach)

  • Thread starter SqlJunkies User
  • Start date
S

SqlJunkies User

The subject about Parent-child retations in two comboboxes was discussed. Here I would like to ask (or may be share) some problems about this subject to find out the right way for this matter.
So, to be more concrete:
The first combo1 is connected to Manufacturers, the second combo2 is connected (or should be connected) to their respective products. Choosing the certain manufacturer in first combo1 should course the combo2 to be filled with the product list of this manufacturer.(actually several controls will also be filled with appropriate data from Products Table)
Here I am faced with the problem which database design to choose:
1. I can make one table only with manufacturers list with ID. I will have the saparate tables for the Products of each manufacturer with the same ID. After that I should somehow make a relations between ONE table with manufacturer list WITH MANY tables of their respective production list. I can use the ID, which will be the same in parent and child table and make the coding for appropriate action (I think that I can)
It is may be good approach, than the sitiation is "static". I mean the list of manufacturers does not change. But if I want to add a new manufacturer I should make an additional table for his products in run-time, fill this table and make the ralationship. It seems difficult to me.
2. Another approach is the following:
I can make the same Table with Manufacturer list as in first example. BUT there will be also ONLY one table called Products, where I will write all the products from all manufacturers with the respective ID, which will be the same as each Manufacturer has. So, when I choose the manufacturer from combo1, the combo2 will find all the products with the same ID (using some sql statement) and fill the combo2. There are no relations here. Just business logic of writen code.
Now what is the question actually. Which of this 2 approachs considered to be best.
AddInfo: the database is not large, maybe 10 manufacturers with 20 products from each.
Thank You in advance
David111
 
J

Jeff Dillon

Have a Manufacturers table and a single Products table. NEVER have multiple
Products tables, one per each Manufacturer. Doesn't make sense.

You can either have a ManufacturerID in the Products table, or have a third
join table ManufacturerProduct

Jeff

SqlJunkies User said:
The subject about Parent-child retations in two comboboxes was discussed.
Here I would like to ask (or may be share) some problems about this subject
to find out the right way for this matter.
So, to be more concrete:
The first combo1 is connected to Manufacturers, the second combo2 is
connected (or should be connected) to their respective products. Choosing
the certain manufacturer in first combo1 should course the combo2 to be
filled with the product list of this manufacturer.(actually several controls
will also be filled with appropriate data from Products Table)
Here I am faced with the problem which database design to choose:
1. I can make one table only with manufacturers list with ID. I will have
the saparate tables for the Products of each manufacturer with the same ID.
After that I should somehow make a relations between ONE table with
manufacturer list WITH MANY tables of their respective production list. I
can use the ID, which will be the same in parent and child table and make
the coding for appropriate action (I think that I can)
It is may be good approach, than the sitiation is "static". I mean the
list of manufacturers does not change. But if I want to add a new
manufacturer I should make an additional table for his products in run-time,
fill this table and make the ralationship. It seems difficult to me.
2. Another approach is the following:
I can make the same Table with Manufacturer list as in first example. BUT
there will be also ONLY one table called Products, where I will write all
the products from all manufacturers with the respective ID, which will be
the same as each Manufacturer has. So, when I choose the manufacturer from
combo1, the combo2 will find all the products with the same ID (using some
sql statement) and fill the combo2. There are no relations here. Just
business logic of writen code.
Now what is the question actually. Which of this 2 approachs considered to be best.
AddInfo: the database is not large, maybe 10 manufacturers with 20 products from each.
Thank You in advance
David111
supports Post Alerts, Ratings, and Searching.
 
Y

yonggangwang

Hi:
You can use DataView to solve your problem;
dataview.RowFilter=mainkey of manufacturer(test)
combo2.datasource = DataView
combo2.displaymember=relation between manufacturer and products;
private sub combo1.selectedIndexChanged
dataview.rowfilter=("test=" & ComboBox1.SelectedValue)

It must be working!

dataview
SqlJunkies User said:
The subject about Parent-child retations in two comboboxes was discussed.
Here I would like to ask (or may be share) some problems about this subject
to find out the right way for this matter.
So, to be more concrete:
The first combo1 is connected to Manufacturers, the second combo2 is
connected (or should be connected) to their respective products. Choosing
the certain manufacturer in first combo1 should course the combo2 to be
filled with the product list of this manufacturer.(actually several controls
will also be filled with appropriate data from Products Table)
Here I am faced with the problem which database design to choose:
1. I can make one table only with manufacturers list with ID. I will have
the saparate tables for the Products of each manufacturer with the same ID.
After that I should somehow make a relations between ONE table with
manufacturer list WITH MANY tables of their respective production list. I
can use the ID, which will be the same in parent and child table and make
the coding for appropriate action (I think that I can)
It is may be good approach, than the sitiation is "static". I mean the
list of manufacturers does not change. But if I want to add a new
manufacturer I should make an additional table for his products in run-time,
fill this table and make the ralationship. It seems difficult to me.
2. Another approach is the following:
I can make the same Table with Manufacturer list as in first example. BUT
there will be also ONLY one table called Products, where I will write all
the products from all manufacturers with the respective ID, which will be
the same as each Manufacturer has. So, when I choose the manufacturer from
combo1, the combo2 will find all the products with the same ID (using some
sql statement) and fill the combo2. There are no relations here. Just
business logic of writen code.
Now what is the question actually. Which of this 2 approachs considered to be best.
AddInfo: the database is not large, maybe 10 manufacturers with 20 products from each.
Thank You in advance
David111
supports Post Alerts, Ratings, and Searching.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top