I see two possibilities: sqlite and BerkeleyDB. Since my use case is clearly not relational, I am tempted to go with BerkeleyDB, however I do not really know how I should use it to store my records, since it only stores key / value pairs.
What you are describing is exactly what relational relationships are, even if you only need one table. SQLite is likely to make this very easy.
EDIT: . . , , (, ) , , x*y = z. (x0,y0,z0) , , .
. -, , . , , , 3-, . , , .
, , , . , , (), ( ), . , , . , , .
. , . , memcached, couchdb, hadoop , . , -, , , , , .
, , , ( )
SELECT t1.actor1
FROM workswith AS t1,
workswith AS t2,
workswith AS t3,
workswith AS t4,
workswith AS t5,
workswith AS t6
WHERE t1.actor2 = t2.actor1 AND
t2.actor2 = t3.actor1 AND
t3.actor2 = t4.actor1 AND
t4.actor2 = t5.actor1 AND
t5.actor2 = t6.actor1 AND
t6.actor2 = "Kevin Bacon";
, , : workswith 6