I'm designing an app that will process a set of social media messages which are posted by users. Each message is then scored and there is a reporting layer that will spit out a set of reports. The app is implemented with spring-boot and has to use a Redis DB.
I'm more familiar with RDBM databases and perhaps I'm being too much of an ORM mapping mindset to this issue.
The main rules i need to enforce
- A user can post multiple messages.
- A message can have multiple scores.
- It should be possible to chart a user's scores over time.
I've started with the logical mapping of data that i believe i need to record in the app. There are three main objects and I'm using spring-data-redis to define the @RedisHash, @Id, @Index and @Reference fields.
Message
The raw message details with thread, date, user and message content.
@RedisHash("messages")
public class Message {
@Id String messageId;
@Indexed String threadId;
@Reference String userId;
String message;
Date date;
@Reference List<User> userScores;
}
Score
A record of a score that each message has been recorded with
@RedisHash("scores")
public class Score {
@Id String id;
@Reference String messageId;
Long score;
@Reference User user;
}
User
The user details with title
@RedisHash("users")
public class User {
@Id String userId;
String grade;
@Reference List<Score> scores;
}
I believe the Message and User objects are correctly defined, but my concern is I've over complicated the Score object mapping. Any comments or advise would be welcome.