how is deletion of the entry in secondary table done

62 views Asked by At

let's assume we have a primary table, with following content:

key  value
--------------
a    andreas
b    bernd
c    chris
e    ernst
f    frank
g    gerold

and we created a seconardy, with a callback that just counts the letters in the primary data, we'll get

5 b
5 c
5 e
5 f
6 g
7 a

now, when I delete the entry for "ernst", the secondary entry "5 e" will be deleted too. How is determined, which secondary entry must be deleted? Does BDB execute the callback again, followed by a table-scan on the calculated value? "5" can be jumped on, but to find "5 e" there would be a cursor needed, right?

1

There are 1 answers

6
Jeff Johnson On

The association between secondary <-> primary in Berkeley DB is on a unique identifier. So with key->value stores, the secondary value == the primary key.

With a unique identifier that associates the secondary <-> primary databases, there is no ambiguity.