0
votes

Using Parse.com "Relations", how do you determine which of the 2 classes should own the Relation?

For example think of WhatsApp groups.

Should User have a relation listing all the groups it subscribes to?

Or should Group have a relation listing all the users in the group?

And, does it make sense to have a relation in each? Duplicating the data?

1

1 Answers

0
votes

Depends on if you want to store some metadata in one of the Classes. It is explained quite nicely in this part of the document:

https://parse.com/docs/relations_guide#manytomany-relations

The decision point here is whether you want to attach any metadata to the relationship between two entities. If you don’t, Parse Relation or using Arrays are going to be the easiest alternatives. In general, using arrays will lead to higher performance and require fewer queries. If either side of the many-to-many relationship could lead to an array with more than 100 or so objects, then, for the same reason Pointers were better for one-to-many relationships, Parse Relation or Join Tables will be better alternatives.

In the whatsapp you have given, Since you have access to user, i think it should be more like what are the groups that user belongs to. Read the many to many relations assuming group as book and users as author. It will make sense