is there a database solution for this ? thanks
Jozef Chocholacek
Jozef.Chocholacek na qbizm.com
Čtvrtek Květen 3 10:40:35 CEST 2001
Nicolas Van Dyck wrote:
> ...
> So, e.g. on the homepage you will have the following combo boxes:
> "Internet", with the values: providers, hosting, webmasters, etc.
> "Hobbies", with the values: music, movie, internet, etc.
> "Countries", with the values: Belgium, Holland, USA, Turkey.
> Say that i choose "Holland" from the Combo Box "Countries", the page has to
> be refreshed, and combo boxes of e.g. "internet" and "hobbies" IN HOLLAND
> schould appear.
> ...
This is mostly not about database engine - you must create *very* sofisticated
data model and set of queries, recommendely stored procedures, to get data from
this DB.
One possible way, direct for your example, is:
create table link ( id int, url varchar ):
1, "www.yahoo.nl"
2, "www.hollywood.nl"
3, "www.yahoo.com"
4, "www.telecom.nl"
...
create table cathegory ( int id, name varchar ):
1, "countries"
2, "internet"
3, "hobbies"
...
create table l2c ( link int, cathegory int, value varchar):
1,1,"Netherland"
1,2,"Portals"
2,1,"Netherland"
2,3,"Movies"
...
Then for initial load of combos you will use something like:
for countries: select value from l2c where cathegory = 1
for internet: select value from l2c where cathegory = 2
etc.
You can also make this to be stored procedure, of course, and using
cathegory name instead of id:
-- Sybase Transact SQL dialect
create procedure getAllCathegory
@cathegory_name varchar
as
select value from l2c where cathegory in
(select id from cathegory where name = @cathegory_name)
Then when user selects "Netherland" in Countries combo, you will use
following queries to fill other combos values:
for internet:
select value from l2c where link in
(select link from l2c where cathegory = 1 and value = "Netherland")
and cathegory = 2
for hobbies:
select value from l2c where link in
(select link from l2c where cathegory = 1 and value = "Netherland")
and cathegory = 3
or as stored procedure:
-- Sybase Transact SQL dialect
create procedure getCathegoryWith1Constraint
@selected_cathegory int -- id of selected cathegory
@selected_value varchar -- selected value in that cathegory
@required_cathegory_name varchar
as
select value from l2c where link in
(select link from l2c where cathegory = @selected_cathegory
and value = @selected_value)
and cathegory in
(select id from cathegory where name = @required_cathegory_name)
and so on. The more combos are selected, the more complex query you
have. And you must do very very good analysis of your problem. Or to
find someone who will solve this for you :)
WARNING: This data model and queries I created "on demand" by QDH
(quick & dirty hack) method, so I cannot recommend to use them without
careful examination and inspection! This is just a quick idea.
COMMERCE: Btw. our company already works on simillar project... why
not to share knowledge?
Best regards,
J.Ch.
--
Ing. Jozef Chocholacek Qbizm Technologies, Inc.
Chief Project Analyst ... the art of internet.
________________________________________________________________
Kralovopolska 139 tel: +420 5 4124 2414
601 12 Brno, CZ http://www.qbizm.com fax: +420 5 4121 2696
Další informace o konferenci Databases