Sign in to follow this  
paul23

Data storage

Recommended Posts

paul23    100
Well this isn't a really specific language question, but rather a generic "programming" question.. Let's say I have 3 independent fields: "name" "phone number" and "age".. Now I would like to store these in such a way I can find them most easily: -most of the time I want to retrieve "age groups". (and get the list of names/phone numbers). -However sometimes a certain "name" would like to change its "data" Is there any data structure that might work for such a thing? (binary trees, sorted by age are my best guess. - but then how would I search for "age between x and y")

Share this post


Link to post
Share on other sites
Hodgman    51339
In a RDB, you'd have a table with those 3 columns, and then you'd tell it to be indexed by age and name, so you can quickly retrieve data using those columns as a lookup.

In any programming language with arrays, you can do the same thing.
You make an array of name/phone/age, then you make an array of indices into the first array which is sorted by age, and an array of indices sorted by name.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this