Help to convert SQL table design to Redis Key => Value store

726 views
Skip to first unread message

Carlos Barreto

unread,
Nov 9, 2015, 2:27:29 PM11/9/15
to Redis DB
Hello, this my first post at community and I’m very excited to work with Redis.

Actually I have a table design and for performance reasons and the number of rows we decided to migrate this table to Redis.

The actual design is attached in the question.

But, my question is, what is the best way to convert this SQL design to Key -> Value storage.

My first, and only, idea is to use at this way:

room:$id:channel:$id:date:$date  => exclusive: 1 nexclusive: 2 units_alloc: 3 units_room: 4

But i don’t now if this is the best way.

Thanks for answers.
SQL_MODEL.jpg

Jan-Erik Rediger

unread,
Nov 9, 2015, 2:37:30 PM11/9/15
to redi...@googlegroups.com
Heho and welcome to Redis,

when working with Redis you have to leave some of the knowledge about
databases behind and think in the opposite way.

How do you need to query the data?

Only with an answer to this question it's possible to discuss the data layout.
There is no single 1:1 mapping from relational databases to Redis that works for everyone.

On Mon, Nov 09, 2015 at 10:42:56AM -0800, Carlos Barreto wrote:
> Hello, this my first post at community and I’m very excited to work with
> Redis.
>
> Actually I have a table design and for performance reasons and the number
> of rows we decided to migrate this table to Redis.
>
> The actual design is attached in the question.
>
> But, my question is, what is the best way to convert this SQL design to Key
> -> Value storage.
>
> My first, and only, idea is to use at this way:
>
> *room:$id:channel:$id:date:$date* =>
>
> * exclusive: 1 nexclusive: 2 units_alloc: 3 units_room: 4*But i don’t now
> if this is the best way.
>
> Thanks for answers.
>
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
> To post to this group, send email to redi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/redis-db.
> For more options, visit https://groups.google.com/d/optout.


Carlos Barreto

unread,
Nov 9, 2015, 2:48:02 PM11/9/15
to Redis DB, jan...@fnordig.de
I need to calculate the values of exclusive/nexclusive values based on this 3 itens:

* Channel
* Room
* Date

Basically a channel has a lot of rooms and every room has a day with Alloc.

I hope I've answered your question.

Carlos Barreto

unread,
Nov 10, 2015, 5:24:10 AM11/10/15
to Redis DB
[edited]

Actually I have a table design and for performance reasons and the number of rows we decided to migrate this table to Redis.
I have a routine to execute some calculations using the alocc.units field. And my algorith make a lot of hits on database to calculate.

As you can see I have for every day in the year an alloc row, referenced by Room and Channel. The only values I have is room.id and channel.id to get the alloc value.

This algorithm is complex and I'm trying hard to explain it. My English it's not the best.

Based on that idea my first, and only, idea is to use a composite of room.id whith channel.id and the date to key:

**room:$id:channel:$id:date:$date**  => exclusive: 1 nexclusive: 2 units_alloc: 3 units_room: 4

Other demand in my algorithm is to retrieve a range of dates of channels to help in calculation.

Thanks again and sorry for my poor and bad initial question.
Reply all
Reply to author
Forward
0 new messages