I have two scenarios showing as the following description, and I would like to know that searching or ordering by document id or document field is a better way according to the time costs or other considerations such as firebase pricing.
A: I set the food name as the document id (assume they are all unique) and each of them has a field called "price", and another architecture B is to make the document a random id and set the food name into the field "name"
These two kinds of architecture can both be used for searching a certain document according to ID or field, but I would like to know if I am going to search for the price of a certain food, then which kind of architecture is better?
A: collection "Food":
document
|- "apple" |- "price" : 10
|- "banana" |- "price" : 13
|- "lemon" |- "price" : 15
B: collection "Food":
document
|- "DXE9JK3V3" |- "name" : "apple"
| |- "price" : 10
|- "VS92S0DV0" |- "name" : "banana"
| |- "price" : 13
|- "VAS0D3JMV" |- "name" : "lemon"
|- "price" : 15
The second question is for document ordering (or maybe for filtering), A: I set the document id as event timestamp string, and each of them has a field called "event", and another architecture B is to make the document a random id and make the time data into the field "time"
I would like to order these documents by the time, according to ID or field, but I don't know which kind of architecture is better?
A: collection "Event":
document
|- "201912201822" |- "event" : "gym"
|- "201912130723" |- "event" : "work"
|- "201911262247" |- "event" : "party"
B: collection "Event":
document
|- "DXE9JK3V3" |- "time" : "2019-12-20 18:22"
| |- "event" : "gym"
|- "VS92S0DV0" |- "time" : "2019-12-13 07:23"
| |- "event" : "work"
|- "VAS0D3JMV" |- "time" : "2019-11-26 22:47"
|- "event" : "party"