I have an appery.io database with three collections - Users, Group, GroupMember. A GroupMember record points to a group and to a user. Now I want to add a fourth collection 'Message' to hold records of group members' messages to each other.
So far I have simply added two pointers in Message to the GroupMember collection, one called Sender and the other called Receiver.
First of all, is this okay? Secondly how can I constrain the relationship so that a) only members in the same group (in GroupMember) can message each other and b) Only n number of messages can be sent by any one sender to another?
Can I add one or both of these constraints at db level or must I use JS validation in the app?