I have a search problem that I'm seeking some advice in. I'm dealing with
the need to search node names in a tree structure that is flattened into a
database table (I have no say over the design, just over how to search). The
tree consists of nodes that represent rooms, cabinets in each room, drawers
in each cabinet, etc. The flattened representation is as what you would
expect--each data row has a column representing the room, cabinet, drawer,
etc. When I search this data, I need to do it in a hierarchical fashion--I
look at the first room, then the first cabinet in that room, then the first
drawer in that cabinet, etc. If I search the dataset linearly, I end up
showing the same hit multiple times (if I hit on the room name, once I finish
showing hits on that row, I encounter the room again the next row). I could,
once a hit is found, move vertically down the column in the dataset, erasing
all names that match, but that isn't easily done without performing multiple
checks to make sure I'm still in the same branch of the tree. Any hints on a
better way to perform this search would be appreciated. I could convert the
data to xml and use xpath, or create a normalized dataset and fill it
appropriately, but I'm not sure this will ease the search later. Thanks.

Re: Hierarchical search of tree flattened to dataset--advise pls by Cor

Cor
Mon Oct 24 09:29:08 CDT 2005

William,

I am absolute not sure if this is what you mean.

http://www.vb-tips.com/default.aspx?ID=3eafa9ea-a906-45ff-aece-e8335682ad3a

This are 3 tables using a parent, child/parent, child relation.

It is however as well possible that you have *one* datatable build by a
join. (What it is probably reading your message).

Than is in my opinion your only possibility way of looping thought the
table.

I hope this helps so far.

Cor



Re: Hierarchical search of tree flattened to dataset--advise pls by W

W
Mon Oct 24 11:24:55 CDT 2005

William - if you can't change any of the rules, IMHO, get out of dataset
land and into XML land using XPath. You can find the room node and use an
Iterator to grab all of the values that correspond to it. There are a few
classes that can do this, but an XPathNavigator and an XPathNodeNavigator
can do it for you.

IMHO, I'd grab the XMl though frmo the dataset and use an XSLT transform
(based on the assumption that the structure of your table will be static)
and then you can easily create a structure that lends itself easily to this
type of iteration. The XSLT may take a little work, but it's probably worth
it as long as the core structure of the document isn't going to change a
bunch. If you can shoot me the core XML from the doc, and what an example
of the resulting output will be, I'll try to take a look at it for you if
you aren't familiar with XSLT or XPath.

HTH,

Bill
"William Sullivan" <WilliamSullivan@discussions.microsoft.com> wrote in
message news:6C4E2E90-56E8-40EF-AEFF-B4340513D980@microsoft.com...
>I have a search problem that I'm seeking some advice in. I'm dealing with
> the need to search node names in a tree structure that is flattened into a
> database table (I have no say over the design, just over how to search).
> The
> tree consists of nodes that represent rooms, cabinets in each room,
> drawers
> in each cabinet, etc. The flattened representation is as what you would
> expect--each data row has a column representing the room, cabinet, drawer,
> etc. When I search this data, I need to do it in a hierarchical
> fashion--I
> look at the first room, then the first cabinet in that room, then the
> first
> drawer in that cabinet, etc. If I search the dataset linearly, I end up
> showing the same hit multiple times (if I hit on the room name, once I
> finish
> showing hits on that row, I encounter the room again the next row). I
> could,
> once a hit is found, move vertically down the column in the dataset,
> erasing
> all names that match, but that isn't easily done without performing
> multiple
> checks to make sure I'm still in the same branch of the tree. Any hints
> on a
> better way to perform this search would be appreciated. I could convert
> the
> data to xml and use xpath, or create a normalized dataset and fill it
> appropriately, but I'm not sure this will ease the search later. Thanks.



Re: Hierarchical search of tree flattened to dataset--advise pls by Sahil

Sahil
Tue Oct 25 00:36:20 CDT 2005

Very interesting problem .. I have one question ..

"What is the search criteria" ?

Are you looking for a particular Cabinet? Is it free form text search?

And what should your search results look like?

A short example would be really helpful.

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
----------------------------------------------------------------------------


"William Sullivan" <WilliamSullivan@discussions.microsoft.com> wrote in
message news:6C4E2E90-56E8-40EF-AEFF-B4340513D980@microsoft.com...
>I have a search problem that I'm seeking some advice in. I'm dealing with
> the need to search node names in a tree structure that is flattened into a
> database table (I have no say over the design, just over how to search).
> The
> tree consists of nodes that represent rooms, cabinets in each room,
> drawers
> in each cabinet, etc. The flattened representation is as what you would
> expect--each data row has a column representing the room, cabinet, drawer,
> etc. When I search this data, I need to do it in a hierarchical
> fashion--I
> look at the first room, then the first cabinet in that room, then the
> first
> drawer in that cabinet, etc. If I search the dataset linearly, I end up
> showing the same hit multiple times (if I hit on the room name, once I
> finish
> showing hits on that row, I encounter the room again the next row). I
> could,
> once a hit is found, move vertically down the column in the dataset,
> erasing
> all names that match, but that isn't easily done without performing
> multiple
> checks to make sure I'm still in the same branch of the tree. Any hints
> on a
> better way to perform this search would be appreciated. I could convert
> the
> data to xml and use xpath, or create a normalized dataset and fill it
> appropriately, but I'm not sure this will ease the search later. Thanks.



Re: Hierarchical search of tree flattened to dataset--advise pls by WilliamSullivan

WilliamSullivan
Tue Oct 25 10:48:08 CDT 2005

I've found that much of my search can be simplified if I use a normalized
dataset to store the results of the search. However, this brings the problem
of filling a normalized dataset with a subset of the data in the database.
I've posted this problem in "Fill related tables in dataset with one query".

"Sahil Malik [MVP]" wrote:

> Very interesting problem .. I have one question ..
>
> "What is the search criteria" ?
>
> Are you looking for a particular Cabinet? Is it free form text search?
>
> And what should your search results look like?
>
> A short example would be really helpful.
>
> - Sahil Malik [MVP]
> ADO.NET 2.0 book -
> http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
> ----------------------------------------------------------------------------
>
>
> "William Sullivan" <WilliamSullivan@discussions.microsoft.com> wrote in
> message news:6C4E2E90-56E8-40EF-AEFF-B4340513D980@microsoft.com...
> >I have a search problem that I'm seeking some advice in. I'm dealing with
> > the need to search node names in a tree structure that is flattened into a
> > database table (I have no say over the design, just over how to search).
> > The
> > tree consists of nodes that represent rooms, cabinets in each room,
> > drawers
> > in each cabinet, etc. The flattened representation is as what you would
> > expect--each data row has a column representing the room, cabinet, drawer,
> > etc. When I search this data, I need to do it in a hierarchical
> > fashion--I
> > look at the first room, then the first cabinet in that room, then the
> > first
> > drawer in that cabinet, etc. If I search the dataset linearly, I end up
> > showing the same hit multiple times (if I hit on the room name, once I
> > finish
> > showing hits on that row, I encounter the room again the next row). I
> > could,
> > once a hit is found, move vertically down the column in the dataset,
> > erasing
> > all names that match, but that isn't easily done without performing
> > multiple
> > checks to make sure I'm still in the same branch of the tree. Any hints
> > on a
> > better way to perform this search would be appreciated. I could convert
> > the
> > data to xml and use xpath, or create a normalized dataset and fill it
> > appropriately, but I'm not sure this will ease the search later. Thanks.
>
>
>