Strategies for managing sorted lists in Firebase -
if had master list of million items, , list of million users, , each user had custom sorted subset of 50 items, immediate way model like:
items [itemid] : { name : 'aaa', description : 'bbb', ... } ... users [userid1] : { name : 'john', token : 'xyz', sorteditems : { itemid1 : xx, itemid2 : xx, ... } }
each user own collection of sorteditems in whatever order needed. problem have have multiple requests per item full item data. after handling updates sorted list, need query master list item data. not big deal, recommended?
another strategy duplicate item data in both master list , sub-lists (or rid of master list). way data right there when need it. obvious problem synchronization. happens if property of item changes? you'd have loop through every user's sorteditems list , update each instance - recipe serious data inconsistencies.
thoughts?
this recommend method. de-normalization common in scalable systems , should work use case.
i recommend duplicating keys only, , not data. way don't have synchronization issue , sharing 1 master state. incur roundtrip when loading each item, note firebase pretty smart handling large numbers of callbacks , caching updates, suspect you'll find it's still quite fast.
Comments
Post a Comment