dbTalk Databases Forums  

Does primary db support duplicate key?

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss Does primary db support duplicate key? in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Wendeline
 
Posts: n/a

Default Does primary db support duplicate key? - 10-27-2005 , 01:57 PM






Hi, I just want to ask, in Berkeley DB, if I set up a primary db, and a
secondary db based on that primary db, can this primary db support
duplicated key?

Another word, if I have a database support duplicated key, Can I add
another index db on this db?

Thanks.


Reply With Quote
  #2  
Old   
Michael Cahill
 
Posts: n/a

Default Re: Does primary db support duplicate key? - 10-27-2005 , 08:02 PM






Hi,

Quote:
Hi, I just want to ask, in Berkeley DB, if I set up a primary db, and a
secondary db based on that primary db, can this primary db support
duplicated key?

Another word, if I have a database support duplicated key, Can I add
another index db on this db?
Not directly, no -- secondary indices use the key from the primary as
the means of associating secondary keys with records in the primary.
So the primary cannot be configured for duplicates.

If you want to achieve something like this, you will need to have some
kind of unique ID as the key in the primary database (say, a record
number), then create *two* secondary indices: one for what you are now
thinking of as the primary key (as a secondary index, it can certainly
contain duplicates), and one for the other secondary key.

See:

http://www.sleepycat.com/docs/ref/am/second.html

for more information.

Regards,
Michael.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.