Forum Stats

  • 3,839,860 Users
  • 2,262,546 Discussions
  • 7,901,083 Comments

Discussions

Multiple secondary keys per primary db record

527197
527197 Member Posts: 27
edited Aug 9, 2006 1:47AM in Berkeley DB
Hello,
The current version of BerkeleyDB supports the generation of one secondary key per primary db record. There are cases when multiple secondary keys per primary db record would be nice.

In my current application each record may belong to one or more types which are stored as a list of numbers within the data-field. With the given limitation I can only index one of these types, because the key-generation-function only allows to return one secondary key.

Are there any plans to add such a feature, e.g. return a list of secondary keys?

As a workaround I have tried to build my own secondary database meachanism- now I appreciate your efforts even more :-). Is there any public material on the way berkeley db keeps the secondary db synchronized? If a new record is inserted the situation is pretty simple- just compute the secondary key and insert it. But what if because of an update an indexed feature is removed from the indexed record? I imagine the lookups are pretty expensive- or the efforts to make it in a convenient time make it very complex...?

This issue is pretty much important for my project. Are there any hints you could give me?

Best regards,

Rüdiger

Comments

  • 522681
    522681 Member Posts: 24
    The current version of BerkeleyDB supports the
    generation of one secondary key per primary db
    record. There are cases when multiple secondary keys
    per primary db record would be nice.
    Yes, we agree.
    Are there any plans to add such a feature, e.g.
    return a list of secondary keys?
    Yes. Unfortunately, this feature has been on our todo list for a few years, we just haven't managed to get the work done.
    As a workaround I have tried to build my own
    secondary database mechanism- now I appreciate your
    efforts even more :-). Is there any public material
    on the way berkeley db keeps the secondary db
    synchronized?
    There's no design documentation of which I'm aware. The code is almost entirely in the distribution file db/db_cam.c, if you're willing to modify the Berkeley DB secondary support directly.
    This issue is pretty much important for my project.
    Are there any hints you could give me?
    If you're coding in Java, you might want to look at the Berkeley DB Collections API, or the Berkeley DB Java Edition product -- both of them support many-to-many indices already.

    Keith Bostic
    [email protected]
  • 527197
    527197 Member Posts: 27
    Thank you for the advice! Iam using the db_cxx (just moved away from Java ;-). I will check the source file you mentioned and post again if I find a convenient extension fit for others.

    Best regards,

    Ruediger
This discussion has been closed.