Should I use an array of pointers or PFRelation? (

As far as I can tell, the only reason you can use an array of pointers is to preserve ordering, as the PFRelation instance does not support ordering. Otherwise, they seem to behave the same, although PFRelation is more scalable and also has a great built-in query method for restricting the query to only objects in the PFRelation instance, which is sometimes very useful.

PFRelation *relation = ...
PFQuery *query = [relation query];


Context: I am building an application where each PFUser instance has many TennisGame instances (can be a lot) and TennisGame instances have many PFUser instances (either 2 or 4 depending on whether it is a solo game or a doubles game) ...

Q: What is the best way to organize my data on I've considered PFRelation in the PFUser class (for TennisGame instances), and an array or 2 or 4 pointers in the TennisGame class (for PFUser instances). But do I need both? If not, which is better?


source to share

1 answer

The question is how do you access your data. In your case, you might think about these questions:

  • Do I need to include the TennisGames user whenever you get a user? If so, arrays are supported include

    on demand. You cannot do include

    with relationships and you need to make another request to access TennisGames.
  • How many TennisGames will a user have in max? If it's likely to be over 100 (the recommended limit in Parse), it's better to go with a relationship. As arrays don't scale to large ratios.
  • As you indicated it, is this an important order for you? If yes, then the order of support for arrays.
  • Again, as you said, if you are interested in a subset of data, relationships can constrain queries, whereas arrays are not.

I suggest you watch this video about Parse relationships from the days of Parse development.

Plus, you don't need to maintain a relationship on both sides. This will make it difficult to create and update.



All Articles