niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Berkeley DB
Creating Primary DB and Secondary DB
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
Michael Cahill
*nix forums Guru Wannabe


Joined: 26 May 2005
Posts: 219

PostPosted: Sun Apr 03, 2005 4:05 am    Post subject: Re: Creating Primary DB and Secondary DB Reply with quote

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

PostPosted: Sun Apr 03, 2005 3:39 am    Post subject: Re: Creating Primary DB and Secondary DB Reply with quote

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

PostPosted: Mon Mar 28, 2005 8:25 am    Post subject: Re: Creating Primary DB and Secondary DB Reply with quote

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

PostPosted: Mon Mar 28, 2005 2:44 am    Post subject: Creating Primary DB and Secondary DB Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 4:27 am | All times are GMT
navigation Forum index » Databases » Berkeley DB
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Secondary db empty susu Berkeley DB 0 Thu Sep 21, 2006 10:37 am
No new posts Creating relational view for an ODBC result set? antilog@gmail.com Server 0 Fri Jul 21, 2006 5:56 am
No new posts Exim4 not creating and/or receiving incoming mail... jtelep@localonline.net Exim 1 Fri Jul 21, 2006 1:59 am
No new posts idea/ concept behind creating breadcrumbs crescent_au@yahoo.com PHP 3 Fri Jul 21, 2006 12:10 am
No new posts (secondary) index-only scans Ryan Berkeley DB 1 Thu Jul 20, 2006 8:32 pm

Air Jordans | Secured Loans | Credit Counseling | Remortgages | Bleach 149 . Bleach 150
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1254s ][ Queries: 20 (0.0514s) ][ GZIP on - Debug on ]