Alex Rivera | Logout

how to have relations many to many in redis

Asked 2012-06-06T03:49:18.460
23

In an relational database, i have an user table, an category table and an user-category table which do many to many relationship.

What's the form of this structure in Redis?

Edit
Report

1 Answer

4

IMHO Redis is not for making structured querys(SQL) but for fast accesible data, what you could do is this: make a "table" with user_id as a key and the data is a list with friends, for example. Then you query for the user_id and process what you need. It's the opposite of normalization. If the order of data is importante, for example status updates, what you do is push and pop data into the lists. For example, the table "status" has user_id as key and the data is a list. You lpush data and then query the last 20 elements for example.

answered 2012-06-06T03:51:50.630

Your Answer