简体   繁体   中英

Google Firestore data organization

As I can see Cloud Firestore and it's collections give us much more power to organize data. For me and many others, I think, there's a basic question.

What's the better approache to store a master detail relation?

Like this : a "CARS" collection with documents that have a "MAKE" property.

I think that I need a "CARS" collection and an independent collection for "MAKES".

Any thoughts ?

Unless you have a specific need, you might be better off just have MAKE as a field each CARS document so you can query for it.

If you want to control MAKE as an enumerated field, you can create a collection called ValidMakes that has documents with ids of all the allowed Makes. In security rules, check that there exists a document with the same id as the MAKE field's value before allowing the write.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM