Database question.....

John D. lists at webcrunchers.com
Thu Aug 7 01:55:46 EDT 2003


I have a small (fewer than a few thousand records) database with the
following properties:

Each record has four fields: A, B, C, D.
Fields A and B are unique:
        there is one B for every A and one A for every B.
Fields C and D are not unique.
Sometimes I need to use A as the key, other times B is the key:
        I use A to return B, C, D and also B to return A, C, D.
The items may all be represented as short ASCII strings.

Currently I am storing this in a 100KB file and converting this to two
dictionaries. I am reading and writing the entire file to update single
records, which is inefficient. I am thinking about using anydbm, but then
how do I do the two-way dictionary lookup? Would I have to store the whole
database twice? What if I had ten items, would I have to store it ten
times? Is this what a relational database allows?

John







More information about the Python-list mailing list