2

I am trying to get my head around the Redis/NoSQL way or designing database but I need some advice. I have the following model:

User {
    long UserId
    string Username 
    string Password
    List<long> ActivityIds 
}

Activity {
    long ActivityId
    long UserId
    long CourseId
    string Name
    string Description
}

I understand that the best way to store a list of activities associated with the user is to store a list of ids. A user can potentially have 500+ activities associated, so I don't really want to load every activity every time I load the user to display a list of them.

Is it possible in Redis and more specifically ServiceStack.Redis to select by a foreign key? For example, select all activities by UserId & CourseId at the same time? Or am I miss understanding the best way to work with Redis?

honk
  • 8,101
  • 11
  • 72
  • 75
Ollie
  • 1,090
  • 8
  • 25

1 Answers1

1

You should be using Id properties for primary keys on models.

Please also read this answer for different ways of maintaining relationships in Redis with the ServiceStack C# client.

Community
  • 1
  • 1
mythz
  • 138,929
  • 27
  • 237
  • 382