Link to home
Start Free TrialLog in
Avatar of HenryM2
HenryM2

asked on

How do I search a large database contained in a Delphi TTreeView?

I have a large databse contained in a Delphi 7 TTreeView.  The database contains equipment with parameters situated on different floors in different buildings on different sites.  The structure of the databse is as follows:
Heading - Level 0
   Site - Level 1
      Building - Level 2
         Floor In Building - Level 3
             Equipment on Floor - Level 4
                  Parameters of Equipment - Level 5

The bulk of the data is on the Equipment Parameter  level  5, where some of the equipment may contain up to 150 lines of parameter information.  The total database is now over 140000 lines in the TTReeView.

I need to search for specific equipment in specific buildings.  When the databse was small my program worked quite well as searching entails the program reading through all the lines when searching for a piecei of equipment.  With the larger size of the database however this in now very slow.

Is there a way to construct some indexing or other methods where the program will be able to search from the index for a building, floor and equipment without having to read through every line on especailly level 5, taking into account that the program is dynamic where equipment on level 4 is constantly added or removed?
Avatar of xr1140
xr1140

the TTreeView is a mean to display the data ... but how is you data stored when the application is not running ... what king of data storage are you using ? If you are using a SQL capable database what you are asking is quite easy to do.

Please give more information.
Avatar of HenryM2

ASKER

On closing of the program the data is converted to an XML file stored on disc. On open the XML file is again converted into the TTrreView where the data is manipulated.
Are you searching through the XML document or the actual tree once loaded?
load the data in a TClientDataSet and use it`s Filter functionality, i think that`s the painless way at this point
Avatar of Eddie Shipman
You can search the XML using XPATH very easily. If you post say two full nodes of the XML I'll show you how to do that as well as return the results to you.
maybe you need to upgrade to an express database (like oracle express or mssql express) or use an embedded database like accuracer
http://www.accuracer.com/client-server_database_single-file_database_delphi_database_embedded_database.htm

your app will load a lot faster and it will not need to save anything at closure.

and you can search directly in the database with sql queries.
Avatar of HenryM2

ASKER

Thanks all so far.  Sounds like there is quite a few possibilities listed.  I am unfortunately out of office till Friday when I will look at these possibilites, please don't loose interest in my problem.

I would just like to mention that the persons using the database is used to expanding nodes in the TTreeView to get certain bits of info.  I also have right click menu funtions which allows the users to copy and paste nodes from one section of the database to other sections.  So once loaded all resides in the TTReeView and manipulated there by either the users or functions being run, manipulating selected parts of the data.
ASKER CERTIFIED SOLUTION
Avatar of HenryM2
HenryM2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
HenryM2:

The way you solved your problem sounds intriguing. Would you be willing to post your code so we can see how you did it?


Avatar of HenryM2

ASKER

The solution has now been operational for a while and works quite well.  At the moment the code is scattered over a few Procedures amongs 6800 lines of code and the Procedure and variable names are appication specific.  Posting it in this state will be messy.  I did this as I was pressed for time to produce the working appication.  I plan to package the solution into a generic set of Procedures as soon as I get time, also so that I can easily reuse the solution myself.  I will then gladly post the solution.  If you are in a hurry for the solution I will make a plan to do it otherwise if for interest sake, I will appreciat if you could give me a few days.