Graph databases would probably also solve this problem. If neo4j is not enough for you in terms of scaling, consider 泰坦, which is based on various storage back-ends including HBase and should scale very well. It is not as mature as neo4j, but it is a very promising project.