I'm building an application and need a data structure of interconnected objects that can be queried and traversed. The connections between objects can be arbitrary and not necessarily known before hand. I need this data structure to be queryable (what usual SQL provides) and also traversable (what new graph database like neo4j provide). I'm trying to get something that does both and works with very large data sets efficiently. Let's call this data structure dao. I would need the following primitive methods:
// dealing with the objects
dao.save(s);
Something s = dao.load(Something.class, 5);
dao.update(s);
dao.delete(s);
// dealing with the relations
dao.relate(s, t);
dao.unrelate(s, t);
// the tricky methods
dao.querier(Something.class).filter(...).sort(...).values();
dao.traverser(Something.class).start(s).path(...).filter(...).sort(...).values();
The filter would be something like the sql where clause, the sort would be something like the sql order clause, the start would be the starting node for the traversal, and the path would define things like BFS and DFS traversing as well as when to stop searching.
I've tried to model this as vertices with an adjacency list but there must be a better way. Any ideas?