I am not sure how I should structure my Firestore database, so it can scale safely. The general structure is a relatively low amount of projects, but each project can have many thousands of subprojects. Is it better to structure the subprojects as a sub-collection of each project or should I structure the project and subproject collection in the root and link the subprojects to the parent project? I try to visualize it. The subcollection object should represent a nested collection
{
"projects": { //collection
"project_uid": { //document
"name": "some_name",
"some_url": "some_url",
"createdAt" : 1548418304
},
"project_uid1": { //document
"name": "some_name",
"some_url": "some_url",
"createdAt" : 1548418304
}
},
"subrojects": { //collection
"subroject_uid": { //document
"thread_uid": "some_id",
"title": "some_title",
"content": "some_content"
},
"subroject_uid1": { //document
"thread_uid": "thread_uid1",
"title": "some_title",
"content": "some_content"
},
"subroject_uid2": { //document
"thread_uid": "thread_uid1",
"title": "some_title",
"content": "some_content"
}
}
}
Or does it make more sense with parallel collections (If this even works)?
{
"projects": { //collection
"project_uid": { //document
"name": "some_name",
"some_url": "some_url",
"createdAt" : 1548418304,
"subcollection": { //collection
"subproject_uid": { //document
"title": "some_title",
"content": "some_content"
},
"subproject_uid1": { //document
"title": "some_title",
"content": "some_content"
}
}
},
"project_uid2": { //document
"name": "some_name",
"some_url": "some_url",
"createdAt" : 1548418304,
"subcollection":{ //collection
"comment_uid2": { //document
"title": "some_title",
"content": "some_content"
},
}
}
}