Converting Many-to-Many relationships into treeview 
Author Message
 Converting Many-to-Many relationships into treeview

Hi,

I have an interesting problem.  Our database keeps track of
CustomerCompany(s), Employees at that company(s), Vendor(s), and Products of
those vendor(s) bought by any CustomerCompany(s).  The database has about
20,000 companies, about 60,000 employees, and about a 100 vendors who sell
about 5,000 products.  I have created a company table, employee table,
vendor table and products table respectively.  The relationships are as
following: a Company can have many employees, and an employee can have
worked for many companies.  A Company can have products from multiple
vendors.  Similarly, a vendor could have sold products to mulitple
companies.  A company can buy multiple products and yet a product could have
been sold to many companies. And so on.

My job is to create a tree view control of which the first level would be
filled with 4 nodes:
                          --ROOT
                                 +CustomerCompany,
                                 +Employee,
                                 +Vendor,
                                 +Product

Someone ought to be able to click the plus on CustomerCompany and see  a
listing of the companies.  So it looks like
                            --CustomerCompany
                                    +ABC Software
                                    +Xircom Systems
                                    +Telco Communications

But then we ought to be able to click the + on Xircom Systems and get this
                           --Xircom Systems
                                    +Employee
                                    +Vendor
                                    +Products

And then if we want, we ought to able to click on Vendors to view all the
vendors that Xircom Systems has dealt with:
                            --Xircom Systems
                                +Employee
                                -Vendor
                                        +Microsoft
                                        +Oracle
                                        +Boeing
                                +Product

Now clicking on Boeing should bring about:
                    --Boeing
                        +CustomerCompany
                        +Products

And so on...............The many-to-many relationship between customers,
employees, products, and vendors have
to be represented in a circular/repeating treeview mechanism.  Another
example would be if say APC sold UPS-10 models.  We would like to track
that.

Clicking through: Vendors-> APC-> Products in treeview hierarchy brings up
UPS-10  as one of the products sold by the vendor: APC.  .  But then by
continuing to click on UPS-10 ->CustomerCompany, ought to bring up all the
companies that have bought this product.  Subsequently, selecting on the
displayed companies that have bought UPS-10 and clicking on them ought to
restart the cycle and we ought to be able to click our way and display the
other products that this company has bought besides UPS-10.

Do you see what I mean?  I have seen something like this done in one of the
Oracle tools.  But I am struggling to get this circular browsing concept
working as a treeview.  Should I encapsulate my tables into classes and go
about it from there?

I appreciate ANY advice and/or feedback.

Mike



Sat, 27 Jul 2002 03:00:00 GMT  
 Converting Many-to-Many relationships into treeview
Maybe you should wait unitl + button is actually pressed and build
children of that node on demand, even delay constructing the database
query. Else you'll need to preload all the data.

With best wishes,
    Igor Tandetnik


Quote:
> Hi,

> I have an interesting problem.  Our database keeps track of
> CustomerCompany(s), Employees at that company(s), Vendor(s), and
Products of
> those vendor(s) bought by any CustomerCompany(s).  The database has
about
> 20,000 companies, about 60,000 employees, and about a 100 vendors
who sell
> about 5,000 products.  I have created a company table, employee
table,
> vendor table and products table respectively.  The relationships are
as
> following: a Company can have many employees, and an employee can
have
> worked for many companies.  A Company can have products from
multiple
> vendors.  Similarly, a vendor could have sold products to mulitple
> companies.  A company can buy multiple products and yet a product
could have
> been sold to many companies. And so on.

> My job is to create a tree view control of which the first level
would be
> filled with 4 nodes:
>                           --ROOT
>                                  +CustomerCompany,
>                                  +Employee,
>                                  +Vendor,
>                                  +Product

> Someone ought to be able to click the plus on CustomerCompany and
see  a
> listing of the companies.  So it looks like
>                             --CustomerCompany
>                                     +ABC Software
>                                     +Xircom Systems
>                                     +Telco Communications

> But then we ought to be able to click the + on Xircom Systems and
get this
>                            --Xircom Systems
>                                     +Employee
>                                     +Vendor
>                                     +Products

> And then if we want, we ought to able to click on Vendors to view
all the
> vendors that Xircom Systems has dealt with:
>                             --Xircom Systems
>                                 +Employee
>                                 -Vendor
>                                         +Microsoft
>                                         +Oracle
>                                         +Boeing
>                                 +Product

> Now clicking on Boeing should bring about:
>                     --Boeing
>                         +CustomerCompany
>                         +Products

> And so on...............The many-to-many relationship between
customers,
> employees, products, and vendors have
> to be represented in a circular/repeating treeview mechanism.
Another
> example would be if say APC sold UPS-10 models.  We would like to
track
> that.

> Clicking through: Vendors-> APC-> Products in treeview hierarchy
brings up
> UPS-10  as one of the products sold by the vendor: APC.  .  But then
by
> continuing to click on UPS-10 ->CustomerCompany, ought to bring up
all the
> companies that have bought this product.  Subsequently, selecting on
the
> displayed companies that have bought UPS-10 and clicking on them
ought to
> restart the cycle and we ought to be able to click our way and
display the
> other products that this company has bought besides UPS-10.

> Do you see what I mean?  I have seen something like this done in one
of the
> Oracle tools.  But I am struggling to get this circular browsing
concept
> working as a treeview.  Should I encapsulate my tables into classes
and go
> about it from there?

> I appreciate ANY advice and/or feedback.

> Mike



Sat, 27 Jul 2002 03:00:00 GMT  
 Converting Many-to-Many relationships into treeview
You definitely want to avoid getting caught in a referential loop.  Don't try to
implement the whole tree at once.  I would look into using a CMap-derived or
CMap-variation class to keep track of nodes that have been created already, to
help avoid infinite recursion.


Sat, 27 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Converting Many-to-Many relationships into treeview

2. Data Relationships- Code says nothing has changed

3. one-to-many relationship in word automation

4. httpwebrequest problem (Could not establish trust relationship with remote server)

5. memcmp - what is relationship?

6. Datagrid issues and parent child relationships

7. Client - Server relationships

8. Relationship between sizeof(unsigned long) and ULONG_MAX

9. HOWTO: Create a parent-child relationship form?

10. Master/detail relationship using CRecordset

11. creating a relationship in Access database with ODBC

12. help creating DAO relationships

 

 
Powered by phpBB® Forum Software