movies: { movieName: { date: 'xxx', actors: { 0: 'actor' }, category: 'category' }, otherMovieName: { date: 'xxx', actors: { 0: 'other actor' }, category: 'category' } }, actors: { actor: { name: 'actor', movies: { movieName: { date: 'xxx', actors: { 0: 'actor' }, category: 'category' } } }, otherActor: { name: 'other actor', movies: { otherMovieName: { date: 'xxx', actors: { 0: 'other actor' }, category: 'category' } } } }, categories: { category: { name: 'category', movies: { movieName: { date: 'xxx', actors: { 0: 'actor' }, category: 'category' }, otherMovieName: { date: 'xxx', actors: { 0: 'other actor' }, category: 'category' } } } }
movies: { movieName: { date: 'xxx', actors: { 0: 'actor' }, category: 'category' }, otherMovieName: { date: 'xxx', actors: { 0: 'other actor' }, category: 'category' } }, actors: { actor: { name: 'actor', movies: { 0: movieName } }, otherActor: { name: 'other actor', movies: { 0: otherMovieName } } }, categories: { category: { name: 'category', movies: { 0: movieName, 1: otherMovieName } } }Hi John,
The most scalable rule of thumb here is to work hard on writes, so that things are easy to read later. In other words, structure the data how it will be read back.
Note that, for your indices, you’ll get into trouble trying to store arrays (e.g. {movies: {0: 'movie1', 1: 'movie2'}}) and you’d probably be better off to store the movies by key with a filler value (e.g. {movies: {movie1: true, movie2: true}}).
But whether you flatten those or not probably just depends on how you’ll read them back. For example, if you want to be able to iterate users without downloading all the movie data, you probably need a more relational format. But you don’t necessarily need that for querying, since you can write queries like firebase.database().ref().child('movies').orderByChild('actors/billpullman').equalTo(true) to fetch movies with a certain actor in them.
Note also that something like an Algolia integration is really what you want for a searchable database. The realtime database is probably usable here, but probably not the best format for search-based data like this (it would be a great tool for synchronizing realtime aspects like comments, voting, et al).
☼, Kato
--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/174f1d90-6122-4dc2-9543-1fe5d66d3de5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.