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?
HenryM2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

xr1140Commented:
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.
0
HenryM2Author Commented:
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.
0
mikelittlewoodCommented:
Are you searching through the XML document or the actual tree once loaded?
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

xr1140Commented:
load the data in a TClientDataSet and use it`s Filter functionality, i think that`s the painless way at this point
0
Eddie ShipmanAll-around developerCommented:
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.
0
Geert GOracle dbaCommented:
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.
0
HenryM2Author Commented:
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.
0
HenryM2Author Commented:
Thanks to all that participated with offers of advice.  Unfortunately the proposed solutions would require major changes to my program.  I therefore wrote my own simple indexing system.  It simply consists of an dynamic array of type String and of type LongWord.  An index is built in this array where the String names of each item on level 4 is added to the array and at the same time the AbsoluteIndex of the string item on level 4 is added to the LongWord Array, both against the same index reference.

When a search is required, it is just necessary to run through the String dynamic index and when a mach is found, the associated LongWord dynamic index contains the AbsoluteIndex for the Equipment Record ||Number EquipRecordNo  of the searched item and
"TreeView9.Selected := TreeView9.Items.Item[EquipRecordNo];" subsequintly selects the appropreate lin in the TreeView.

Naturally the Index is maintained when items are added and deleted from the TTreeView.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
surfboredCommented:
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?


0
HenryM2Author Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.