This problem description is nearly incoherent.
You can regard it as a efficient implementation of undirected graph.
Relational DB can do it very well with something like:
create table image2tag ( varchar image, varchar tag, primary key (image, tag), index (image), index (tag) );
You could use indirection:
key1=>valueID key2=>valueID valueID=>value
Not what you asked for (and certainly not what the cool kids use), but why not?
Edit: oddball requirements == things that relational databases dont do well like text.
Searching for the intersection of a set of tags' references seems like the epitome of a set/relational operation to me.
Finding intersections with tags are multi-way joins, which are painful as all hell. At least on MySQL. Perhaps other databases do better.
Note that I built probably the biggest platform of this type around.
- a target (such as an URL in delicious)?
- a [target, user] pairing?
- a [target, user, tagging-event] tuple?
Would you recommend using any of the off-the-shelf open-source inverted-index implementations? (Lucene, ferret, sphinx, [hyper]estraier, etc.?)
I think Lucene or Sphinx will take you a lot of the way. I don't know about the others.
If you want to do an intersection you can, unfortunately it's in a sorted order. for example: [key1, key2, key3] won't match [key2,key1, key3]
If you're trying just get all images matching a key so your structure looks like:
{img (url, binaray, etc), tags: [tag1, tag2, tag3, tag4]}
you can run a simple map function over the data function map (doc)
{
for each (var tag in tags)
emit (tag, null);
}
which will allow you to then get all images by tag: key=tag
It doesn't have a c++ api, but it uses http as its interface so you can use curl..CouchDB is great, but that's just one description you don't want your database server to fit. Go for boring, stable and tried and true.
Based on the few details you've given, I'd consider SQLite (http://sqlite.org/). It's relational, but very lightweight and runs in-process. It's also open-source, quite mature, simple to use, and interfaces very easily with C.
For all we know, he's using the above because he doesn't like (or understand?) SQL/relational theory, or because of vague stuff he keeps hearing about MySQL not scaling. I'm not assuming he's ignorant, but we don't know why he started with memcachedb, et al, and those reasons are worth ruling out first.
The constraints on the problem (how much simultaneous r/w access, size of the data set, etc.) will have the most impact on what to choose, but it doesn't seem like you've fleshed that out anywhere else in the thread.