I want to use a datastructure like this:
building string (indexed)
date TDate (indexed)
room_id integer (indexed)
measurement_data -> various fields
To change a database query in that’s in a remote SQL server.
This way I only have to query the database once for a given building and I can use a Delphi middleware application to hand out individual data items to a backend.
What kind of data structure would you recommend for storing this stuff, so that I can retrieve data items quickly.
I was thinking of putting it in a class with the above items and putting the objects in a TStringList, but then I only have 1 index on the data.
Because I’m retrieving individual items mostly I don’t want to use a clientside DB.
Is there a better TList variant that will let me retrieve an item quickly.
In other words, TStringlist (with attached) objects only allows one index. (the string) is there a better List that will allow multiple indexes?
EDIT
TCollection sounds like a much better match, is that a good idea?
In one of my old projects (around Delphi 7) I did this by having multiple
TLists storing pointers to records. One of the lists owns the items and is responsible for cleanup, the others point to the same items but each list is sorted differently, serving as indexes for binary search lookup. Other then their order, the lists are identical and kept in sync – adding an item adds to all the lists, removing an item removes from all the lists.Another option would be to use
TClientDataSetor another in-memory dataset with indexing support.