Reputation: 4755
If I have a class titled Article
, and I want to add an Author
column (which is class type User
), should I use relation or pointer? There can only be one Author
, but that Author
can write many articles. I'm assuming pointer, but just making sure.
Thanks!
Upvotes: 9
Views: 5193
Reputation: 1145
If you assume that an article will have 1 or 0 authors, then use a pointer. If there may be more than one author, use an Array.
When you have a one-many relation, you have a choice of using arrays or PFRelations. Arrays are a lot easier to deal with if the max number of entries is not large, let's say 100 or less. Perhaps the most important advantage is that you can use includeKey when querying to bring in all the related objects with one query.
If the number of related objects is large, you have to use PFRelation.
Upvotes: 17
Reputation: 1916
A general rule of thumb is to use a pointer for one-to-one or one-to-many relationship. Use a relation when you have a many-to-many relationship. I would say in your case it sounds like you want to use a pointer type. This guide is useful.
Upvotes: 1