Redis search between primary and child

40 views
Skip to first unread message

karthi djax

unread,
Mar 7, 2022, 8:37:51 AM3/7/22
to Redis DB
Hi

There is a scenario like one primary id such as 123 many child id's need to map with that primary id and need to get primary id using anyone of child.

Requirement:
- One key
- Multiple primary keys with many child data inset, remove capability
- Each primary key can contain n number of child data
- Need to get primary by scanning child id

Hope will get better solution, thanks in advance..

Oscar Besga

unread,
Mar 7, 2022, 1:44:38 PM3/7/22
to Redis DB
For primary key - child, use a list; with primary id as list name and child keys as values

For child - primary, use a simple string value with name child-id and value the primary key

use transactions to add/remove data to mantain integrity
Reply all
Reply to author
Forward
0 new messages