我想在firestore中创建一个数据库。我对noSQL不太了解。我有多个类型A的字段,对于每个字段,我都应将其映射到类型B的数组,并且每个B都必须映射到键值映射。谁能在Firestore中帮助我创建此类建模?
示例:如果您仍然不清楚,这是我如何存储数据的直观视图
Class 1 ->Student A -> height of A : x
-> weight of A : y
-> marks of A : z
->Student B -> height of B : a
-> weight of B : b
-> marks of B : c
Class 2 ->Student D -> ...
至少有人能推荐一些博客或教程来在Firestore中进行复杂的数据库建模吗?在此先感谢:)
答案 0 :(得分:0)
在我看来,这相对简单。
Collection "Class 1"
-> Document "UserId"
-> Document Field "Name"
-> Document Field "Weight"
-> Document Field "Marks"
....
-> Document "UserId"
-> Document Field "Name"
-> Document Field "Weight"
-> Document Field "Marks"
....
//Second class will be a different collection
Collection "Class 2"
-> Document "UserId"
-> Document Field "Name"
-> Document Field "Weight"
-> Document Field "Marks"
....
-> Document "UserId"
-> Document Field "Name"
-> Document Field "Weight"
-> Document Field "Marks"
....
但是,如果您创建的是学校之类的东西,那么这仍然有效,但是您可以在前面进行其他查询以保持数据库的结构化。示例:
Collection "SchoolName"
-> Document "Classes"
-> Collection "Class Name"
-> Document Attendee "UserId"
-> Document Fields "Name"
-> Document Fields "Weight"
...
-> Document Attendee "UserId2"
-> Document Fields "Name2"
-> Document Fields "Weight2"