I'm seeing mixed tutorials in Firebase that recommends to structure data like this:
posts: {
post_1: {
title: 'Some Title',
comments: {
comment_1: true,
comment_2: true,
...
comment_x: true
}
}
}
comments: {
comment_1: {
name: 'Foo'
},
comment_2: {
name: 'Bar'
},
...
comment_x: {
name: 'X'
}
}
and
posts: {
post_1: {
title: 'Some Title',
}
}
comments: {
post_1: {
comment_1: {
name: 'Foo'
},
comment_2: {
name: 'Bar'
},
...
comment_x: {
name: 'X'
}
}
}
I think the latter is better in terms of speed when querying, bulk writing, and security flexibility. Especially that when you have the 1st data structure and you query over the blogs just to find out it's title since it'll load all comments even if it only has a value of true, for a million records, that's still a lot of data to download from the client (unless I'm missing something here).
My question is, for heavy data like those in social networks, is the 2nd data structure really that better compared to the 1st one? I'm not even convinced that the 1st one is better at any area than the 2nd one at all.
I'm torn because some Firebase tutorial uses the 1st data structure and I'm using the Emberfire web library from Firebase which enforces it if you want to completely embrace the library.
Aucun commentaire:
Enregistrer un commentaire