FatFractal customer forums



Author Topic: Grabbag vs Using BackReference  (Read 1920 times)

kwylez

  • Newbie
  • *
  • Posts: 27
    • View Profile
Grabbag vs Using BackReference
« on: January 08, 2014, 05:00:10 PM »
I have the below models. Is it necessary to have both a reference (from Photo to Event) and a grabbag of photos on Events or would it be a better data model to just have the reference on Photo object and if I want all the pictures in an Event just use a back reference query?

Code: [Select]
CREATE OBJECTTYPE Event (name STRING, location REFERENCE /Venues, attendees REFERENCE /FFUserGroup, startTime DATE, endTime DATE, isPrivate BOOLEAN, photos GRABBAG /Photos, ownerProfile REFERENCE /Profiles)
CREATE OBJECTTYPE Photo (event REFERENCE /Events, owner REFERENCE /Profiles, accessGroup REFERENCE /FFUserGroup, image BYTEARRAY, previewImage BYTEARRAY, thumbnailImage BYTEARRAY, iPhoneFullsizeImage BYTEARRAY)

gkc

  • Administrator
  • *****
  • Posts: 375
    • View Profile
Re: Grabbag vs Using BackReference
« Reply #1 on: January 08, 2014, 06:48:20 PM »
Usually with hierarchical relationships it's better to have the relationship from child to parent (Photo to Event). There's zero difference in terms of performance of getting all Photos for an Event; plus, you have less data maintenance to do (and less API requests to make)

Additionally, when a child refers to a parent like this, it makes it possible to use our cascaded permissions model! See here: http://fatfractal.com/prod/docs/permissions/#cascading-permissions-using-intermediate-references

Cheers,

- Gary
« Last Edit: January 08, 2014, 08:40:28 PM by gkc »

kwylez

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Grabbag vs Using BackReference
« Reply #2 on: January 08, 2014, 07:52:55 PM »
Thanks Gary...I'll update my app

 

Copyright © FatFractal customer forums