0

I read some documentation but no clear answer to this question. In fact, I have a presence training list with about 200 childrens. A corresponding App android app is available.

My dilemma is that in the first version only the "isSelected" is changed but in the second all users are created each time again. Is that not a kind of resources wasted that should be avoided?

If you have some practical experience, please let me know which model suits best. Many Thanks!

Model 1

>>Collection
  "users"             
        >>Document
          "Chuck_Norris"
               >>Data
                 uid: someuid             
                 username: Chuck Norris
                 profileImageUrl: chnoris.jpg
                                               >>Collection 
                                                "Training day" 
                                                    >>Document
                                                      "2019_02_21"
                                                                >>Data
                                                                  isSelected: false
                                                      "2019_02_22"
                                                            >>Data
                                                                isSelected: false
                                                      "2019_02_23"
                                                            >>Data
                                                                isSelected: false

or Model 2

>>Collection
    "Training day"

          >>Document
             "2019_02_21"     
                     >>Collection
                            "users"    
                                 >>Document
                                   "Chuck_Norris"
                                       >>Data
                                         uid: someuid             
                                         username: Chuck Norris
                                         profileImageUrl: chnoris.jpg
                                         isSelected: false

              >>Document
                 "2019_02_22"     
                         >>Collection
                                "users"    
                                     >>Document
                                       "Chuck_Norris"
                                           >>Data
                                             uid: someuid             
                                             username: Chuck Norris
                                             profileImageUrl: chnoris.jpg
                                             isSelected: true

              >>Document
                 "2019_02_23"     
                         >>Collection
                                "users"    
                                     >>Document
                                       "Chuck_Norris"
                                           >>Data
                                             uid: someuid             
                                             username: Chuck Norris
                                             profileImageUrl: chnoris.jpg
                                             isSelected: true
Java bee
  • 2,522
  • 1
  • 12
  • 25
  • 1
    With NoSQL databases, you should structure your data in a way that supports your intended queries. There is no "right" or "wrong". – Doug Stevenson Feb 21 '19 at 15:59
  • 1
    You can also check **[this](https://stackoverflow.com/questions/53053768/what-is-the-correct-way-to-structure-this-kind-of-data-in-firestore/53057707)** out. – Alex Mamo Feb 21 '19 at 16:40
  • I have read your post link, Thank you Alex for your great contribution. My dilemma is that in the first version only the "isSelected" is changed but in the second all users are created each time again. Is that not a kind of resources wasted that should be avoided? – Java bee Feb 22 '19 at 10:12

0 Answers0