I need to track users relations in a social app, something like this:
UserA follow UserC, UserD, and UserE
UserZ follow UserC, UserD, and UserE
UserC follow UserA, UserD, and UserE
And so on.
First, I need a partition tolerant database so MySQL and its brothers are out of the game.
I look at couchdb but it creates a revision for each change, so, if your doc is like:
{
uuid: uuid
name: name,
lastName: lastName
follows: [ uuid1, uuid2, uuid3 ]
}
you will have this other revisions in the data base
(rev 1)
{
uuid: uuid
name: name,
lastName: lastName
follows: [ uuid1, uuid2 ]
}
(rev 2)
{
uuid: uuid
name: name,
lastName: lastName
follows: [ uuid1 ]
}
That is a lot of space, I know you can free this by some manual action but the problem don’t disappear.
I look at Cassandra, and so far it looks like a good solution, it allows insertions with no extra space issues like couchdb. I can create a key space, then a column and then an store relations, something like this:
keyspace:{
column:{
...
uuidT:{ uuidA: timestamp, uuidB: timestamp, uuidZ }
uuidF:{ uuidA: timestamp, uuidB: timestamp, uuidZ }
uuidH:{ uuidA: timestamp, uuidB: timestamp, uuidZ }
...
}
}
But I’m wondering if a graphical database is best for this.
Edit:
After surf for a answer I found this page that helps to chose a DB. http://nosql.findthebest.com/
FWIW, in CouchDB I always use arrays of objects, rather than just arrays of IDs. Eg.
This is for two reasons:
{ _id: uuid1, followed_on: "2011-10-22" }include_docs=trueoptions for grabbing the associated doc in your view queries.Update
Hey, check it out, you can limit the number of revisions kept in the DB