skip to Main Content

I have a question regarding the formatting of data in a nosql database

I have the following use case:

n User can be in 
n Groups where each user has
   1 time goal per day
   1 time he is currently tracking (which increments during the day)

The goal: Each user works toward a goal (in minutes) per day and can see each others progress.
The hardest part for me is the time goal. I have no idea how to structure that.

My thinking right now:

Users
    unique_id:
        name: user1
        timeTracked:{
              {11.02.2023:45}
        }groups:[group1, group2, group3]
groups
    groups1:
        members:{user1,user2...}
        time:{
              22.02.22:{
                    user1:43
                    user2:60
              }....
        goals:{
              22.02.22:{
                    user1:80

Would that be a sensible way of structuring the data? That would make it quite hard to track if users have achieved their goals in the past: If I only have a timestamp from 05.02.22 because the user didn’t change their current goal, I would have to extrapolate it for the days up until 11.02.22

2

Answers


  1. I would suggest to make a separated collection for each user’s time goals.
    The separated collection will store the users’ time goal for a specific day.

    user_id: "user1"
    date: "2020-02-15"
    goal: 54
    

    You will be able to track each user’s progress towards their goal for each day easily, even if they don’t update their current time tracking.

    Login or Signup to reply.
  2. It is difficult with only this data. But I think that a structure that represents the objectives by group and user can help.

    "Users": {
        "user1": {
            "id": "user1",
            "name": "Alice",
            "groups": [
                "group1",
                "group2"
            ]
        }
    },
    
    "Groups": {
        "group1": ["user1", "user2"],
        "group2": ["user1", "user3", "user5"]
    },
    
    "Goals": {
        "group1": {
            "user1": {
                "22-02-2023": {
                    "goal": "30",
                    "work": "22"
                },
                "23-02-2023": {
                    "goal": "20",
                    "work": "21"
                }
            },
            "user2": {
                "22-02-2023": {
                    "goal": "30",
                    "work": "22"
                },
                "23-02-2023": {
                    "goal": "20",
                    "work": "21"
                }
            }        
        },
        "group2": {
            "user1": {
                "22-02-2023": {
                    "goal": "10",
                    "work": "12"
                },
                "23-02-2023": {
                    "goal": "15",
                    "work": "20"
                }
            },
            "user3": {
                "22-02-2023": {
                    "goal": "35",
                    "work": "18"
                },
                "23-02-2023": {
                    "goal": "10",
                    "work": "10"
                }
            }        
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search