![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I would like to be able to perform searches on the database of the kind: "Find all the database entries where key field B==value_to_match regardless of what is in the other fields". In order to achieve this I would like to pass to my btree comparison function a structure initialised with: struct my_key search_key; search_key.A = IGNORE_ME; search_key.B = value_to_match; search_key.C = IGNORE_ME; |
#3
| |||
| |||
|
|
Mark Stevens <mas78910 (AT) hotmail (DOT) com> wrote: I would like to be able to perform searches on the database of the kind: "Find all the database entries where key field B==value_to_match regardless of what is in the other fields". In order to achieve this I would like to pass to my btree comparison function a structure initialised with: struct my_key search_key; search_key.A = IGNORE_ME; search_key.B = value_to_match; search_key.C = IGNORE_ME; I don't think you can do that; or if you can, it's a bad idea. The problem is that the comparison function is used not only for searches, but also for *constructing* the BTree --- it defines the sort order of entries in the database. This sort order is exploited when running searches, too. Having an essentially unsortable key field value like your "IGNORE_ME" violates this structure. |
|
You should rather store your data as data in a RECNO or other database, and set up a secondary index database for every field of struct my_key. |
#4
| |||
| |||
|
|
What I am suggesting is to use incomplete structures (i.e. with some fields marked as IGNORE_ME) for *searching* the database. |
|
I'm a bit reluctant to do this since the structures that I'm dealing with are going to have at least 10 fields (possibly many more). Is there an easy way to set up large numbers of secondary indices without doing everything by hand? |
#5
| |||
| |||
|
|
Well, maybe BerkeleyDB isn't for you, then. Automatic handling of such indices is one of the reasons the elders invented relational database management systems... |
#6
| |||
| |||
|
|
Mark Stevens <mas78910 (AT) hotmail (DOT) com> wrote: I'm a bit reluctant to do this since the structures that I'm dealing with are going to have at least 10 fields (possibly many more). Is there an easy way to set up large numbers of secondary indices without doing everything by hand? Well, maybe BerkeleyDB isn't for you, then. Automatic handling of such indices is one of the reasons the elders invented relational database management systems... |
#7
| |||
| |||
|
|
Mark Stevens <mas78910 (AT) hotmail (DOT) com> wrote: I'm a bit reluctant to do this since the structures that I'm dealing with are going to have at least 10 fields (possibly many more). Is there an easy way to set up large numbers of secondary indices without doing everything by hand? Well, maybe BerkeleyDB isn't for you, then. Automatic handling of such indices is one of the reasons the elders invented relational database management systems... |
#8
| |||
| |||
|
|
Berkeley DB can automatically maintain large numbers of secondary indices, it's not a problem. You have to create a secondary index function for each one, and call the Db.associate method to associate the two databases, but that's not a lot of work. |
#9
| |||
| |||
|
|
bostic (AT) sleepycat (DOT) com (Keith Bostic) wrote in message news:<adecb6f.0309020853.3ed322aa (AT) posting (DOT) google.com>... My understanding from the RPC docs is that the primary and secondary databases must be created locally on the server. I take this to mean that the application which writes to the primary and secondary databases cannot do so via RPC - it must be running on the machine where berkeley_db_svc runs. From the docs it appears that any client which needs to search the database using secondary indices may do so via RPC so long as it opens the primary and secondary databases as DB_RDONLY. Is all this correct? |
![]() |
| Thread Tools | |
| Display Modes | |
| |