Re: Data Structure Questionby GrandFather (Cardinal)
|on Nov 25, 2009 at 21:12 UTC||Need Help??|
Your data could be stored in many ways. The key to choosing a data structure tends to relate to how you most often want to access it and how easy it is to write and maintain reliable code to manage it.
You could for example use an array of arrays - one entry per record where each record is an array containing three elements. That's good if you want to process all the data every time you perform a query, but is a maintenance nightmare if you ever need to change the number of fields in a record. Even just coding in the first place can be nasty unless you use named constants to access the individual elements in a record.
You could use an array of hashes which has most of the advantages of the AOA above, but provides named access to the fields in the records making coding and maintenance easier at the cost of needing more memory for storing the data.
If you need to access the data by some key field then a HOA or HOH is appropriate.
If you need to access the data by more than one key or there is more data than you really want to fit into memory, then you should use a database. That can actually be a lot simpler than you might think. Consider:
True laziness is hard work