Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

int/int/string storage and retrieval

Status
Not open for further replies.

mgabbert

Programmer
Sep 25, 2003
9
0
0
US
I would like to be able to store and retrieve tripples of information quickly and easily.

The tripples would consist of:
int systemID (will change at runtime)
int objectID (all known at runtime)
string attributeName (all known at runtime)

I will have to search and retrieve the following types of queries:
systemID/objectID/*
systemID/objectID/specific attributeName

Is there an easier way and more effective way, than either:
a) storing all 3 in a datatype and then doing a linear search of all the entries
b) creating an array of all objectIDs. For each objectID create an array of attributeNames. For each attribute name have an array of the systems that correspond.

Thank you, and if I can provide any more information, please let me know.

-matt
 
This sounds like a good case for using a database. The relational model is set up for just this sort of thing.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
I agree, but a database is not an option for this component.
 
Then I would do this:
1. Create a class to hold your tuple.
2. Store your classes in an ArrayList
3. Create several NameValueCollection objects to act as indexes into the ArrayList (One for ObjectId, and one each for each Attribute you want to retrieve via).

This will allow you to do fast lookups (find a value from the NameValueCollection, use it as an index into the ArrayList), at the penalty of having slower insert times (each new value added to the ArrayList needs index values inserted into all the NameValueCollections).

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top