I think cross referancing is a good way of learning. I made some research on redis and it seams that as a schameless database redis don't have tables. Instead of tables it has got key-value, key-list, key-set and key-sortedset(zset) pairs.
This kind of key-data pair structure is too unfamiliar for me. I'm more used to mysql, sql styled databases.
I got a sqlFiddle here it demonostrates a simple inner join example.
I offenly take this data from sql and re-model it to a meaningfull JSON object like this:
var posts = {
users: [{
userid: 1,
posts: [{
header: "header1",
content: "content of header1"
},{
header: "header2",
content: "content of header2"
},{
header: "header3",
content: "content of header3"
}]
},{
userid: 2,
posts: [{
header: "header4",
content: "content of header4"
}]
}]
}
My question is:
How can I mimic this kind of table structure on redis and node.js? Is there a build in redis command for foraign keys? If I have no option but using app level data re-modeling how is the proper way to doing that kind of process.
PS: Cross referancing examples and usefull articals would be apriciated.
EDIT: Is join like operations can be done by SINTER command of Redis?
Redis is a key-value store and not a relational database. As such, there is no native function that would maintain entity relationships. If you wanted it, you'd have to write this into your app.
The closest thing I can think of is what you find in the Mongoose.js module. Mongoose defines a Schema that defines fields used to format and validate documents fetched/saved with MongoDB and also allows for subdocs which could possibly start to mimic relationships between entities.
...but considering that Redis has a record expiration/TTL feature built-in, that records are stored in RAM, that it's a key-value store....it feels a misplaced effort to attempt this. Even Mongoose doesn't provide functionality to enforce referential integrity between collections and limits help to improving record consistency with validation/typing via its Schema.