Hi Per,
Quote:
So far so good, secondary databases are there to do just that, but some
of the songs have more than one author. How am I going to do this? The
key extractor callbacks does only seem to allow creation of one record
per record.
Are there any ways to do this, or do I need to do this manually (using
only primary databases)? |
Berkeley DB's associate call doesn't directly support what you need.
There is a limited way to do this that might work here. If you can put
an upper bound on the number of authors (if, say, no song ever has more
than five authors), then you can open that many handles on the
secondary (author) database, and associate handle with the primary.
You'll need a separate callback to extract the first author, the second
author, and so on.
The callbacks can return DB_DONOTINDEX if a song doesn't have that many
authors, so the secondary won't be bloated. And all of the authors end
up in the same database, so you can search for an author without having
to know whether s/he is the first or second author of a song.
The big limitation, of course, is fixing the maximum number of
secondary keys, and the clunky setup. Sleepycat have discussed
implementing 1:N secondary indices, but as far as I know it isn't on
anyone's schedule. If this feature is of general interest, please let
us know.
Michael.