Hierarchical search of tree flattened to dataset--advise pls

G

Guest

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.
 
W

W.G. Ryan - MVP

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
 
G

Guest

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".
 

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