Flutter + Firebase: Is it viable to store the name of a group as the FireStore Collection name?

Viewed 46

I am trying to develop a Workout Tracker and am confused as to how I would go about developing a good structure and why it is considered one - and how it'd perform when retrieving data from Google FireStore using Flutter.

In terms of the structure of the data, every User has a subcollection called 'Groups'. A 'Groups' subcollection has 2 fields ('name' & 'description') and will contain more subcollections relating to the different workout template in that group.

Would it be efficient (when implementing methods to retrieve data, etc) to store each subcollection as the name of their workout and have each document in the subcollection as the index of where the specific exercise is placed within the workout. For a more visual representation, I have included an example. '+' shows a subcollection name and '*' shows a document name

-+ Groups
--* Auto-ID
--- 'name'
--- 'description'
---+ Push
-----* 1
------ 'exercise'
------ 'note'
------ 'reps'
------ 'weights'
-----* 2
------ 'exercise'
------ 'note'
------ 'reps'
------ 'weights'
---+ Pull
-----* 1
------ ...
---+ Legs
-----* 1
------ ...

enter image description here enter image description here

In terms of implementation, I was thinking of using Flutter to retrieve all subcollection names (Push/Pull/Legs) within each group to display it and then to order the workouts within each template by the name of the document.

I'm not sure how efficient this is but I've also considered have Auto-ID for all subcollections and instead just storing it in a field - but why not just save it as the ID if it's going to be unique. In terms of the document names (1/2/3/4..) for each exercise in a template; I was debating wether to have a field called 'position' or just keeping it like this.

Any tips would be gladly appreciated and an explanation with it so I can further understand it!

0 Answers
Related