I have created a project involving students at schools. As I have started to build this project I have encountered three major questions:
1) Which JSON tree structure is recommended or better?
schools
grades
users(uids)
info
or
users(uids)
info (includes school and grade)
2) If I were to use the first structure, how would I access the user's grade and school, which is vital to be able to access the rest of the user's contact information, upon first logging in?
3) If I were to use the second structure, wouldn't it be too many users to query through to find all the people in one grade of one of many schools?
Somebody please help. At this point, I'm just super confused.
Before getting Into it mark some points which are best practices for firebase :-
for more info - check this link
I feel below JSON structure will be nice. I'm not sure of it as I don't know exact requirement of yours. It depends on your requirement. But always the recommended way is to try to create more independent nodes as you can access data through queries.
schools
users(uids)
Grades or info based on relation between grades and users
Just make separate nodes for user's info, and the other node for member of grade of school
schooldb
schools
grades
users(uids)
and for getting info
userdb
users(uids)
info (includes school and grade)
This is a necessary redundancy for two-way relationships
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.