| Author |
Message |
Michael Cahill *nix forums Guru Wannabe
Joined: 26 May 2005
Posts: 219
|
Posted: Sun Apr 03, 2005 4:05 am Post subject:
Re: Creating Primary DB and Secondary DB
|
|
|
Searching with DB_SET_RANGE uses the b-tree structure, it isn't a
linear scan.
Michael. |
|
| Back to top |
|
 |
Wendeline *nix forums beginner
Joined: 26 Mar 2005
Posts: 17
|
Posted: Sun Apr 03, 2005 3:39 am Post subject:
Re: Creating Primary DB and Secondary DB
|
|
|
Hi,
Using DB Cursor and set the flag to DB_SET_RANGE, does it mean the
cursor will actually travsers sequentially all the record untill it
finds the right id or it use b-tree algorithm to traverse ? If it is
the first case, then having three b-tree databases should be better
than having two databases? Am I right? |
|
| Back to top |
|
 |
Florian Weimer *nix forums Guru
Joined: 19 Feb 2005
Posts: 418
|
Posted: Mon Mar 28, 2005 8:25 am Post subject:
Re: Creating Primary DB and Secondary DB
|
|
|
| Quote: | Then I create two secondary DBs to associated with the primary DB,
one with id as secondary key, the other with string as secondary
key...Ended up I have to create 3 DBs to have the above 3 behaviors
working.
|
You could use the (id, string) table and DB_SET_RANGE to look up
records based on their IDs. This way, you only need two tables. |
|
| Back to top |
|
 |
Wendeline *nix forums beginner
Joined: 26 Mar 2005
Posts: 17
|
Posted: Mon Mar 28, 2005 2:44 am Post subject:
Creating Primary DB and Secondary DB
|
|
|
Hi, I need a database for storing ids and strings, showing the
following behaviors:
i) Both id and string can have duplicates
ii) id+string is unique.
iii) id->string mapping and string->id mapping should be available.
I tried to create a primary DB with id as the primary key and associate
it with a secondary index DB with string as secondary key, then I
realized that primary key may not be configured with duplicates. So I
guess I have to create a primary DB with id+string as the key, and
data could be the same value as key or even null since all the
information are included in the primary key. Then I create two
secondary DBs to associated with the primary DB, one with id as
secondary key, the other with string as secondary key...Ended up I have
to create 3 DBs to have the above 3 behaviors working.
Could there be a simplier way to do this? |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|