# Realtime DB parent/child

**URL:** <https://community.thunkable.com/t/realtime-db-parent-child/590669>\
**Category:** Questions about Thunkable X\
**Created:** [May 28, 2020, 10:46pm UTC](https://community.thunkable.com/t/realtime-db-parent-child/590669 "2020-05-28T22:46:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesx](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jamesx](https://community.thunkable.com/u/jamesx)\
**Post date:** [May 28, 2020, 10:46pm UTC](https://community.thunkable.com/t/realtime-db-parent-child/590669/1 "2020-05-28T22:46:28Z")

</div>

Hi Everyone

I’m trying to create an app which a PT will use to set workouts for their clients. To do this, I’m trying to set up a parent/child structure in realtimeDB.

This way, when a PT logs in, they can create a list view at the PERSONAL TRAINER level so that they can see all of their clients’ details, and add workouts and other data.

If a client logs in, they will see only their data and whatever additional data a PT has set for them.

**What I am trying to achieve**

The ideal will be -

1. User is invited to use the app (I want a closed beta initially)
2. If they’re a returning user, they’ll simply authenticate then go into the app, where they see the data that their user type should have access to
3. If they’re a new user, their authentication details will be used to set up a new entry into the database at the correct level

**What I’ve done so far**

I was going to put screenshots too, but I have a max 3 images per post as a new user… Let me know if you want to see them.

1. Determine whether this is a new or returning user and direct them to the correct place. This isn’t how I wanted to do it, but I guess it works…  

2. Create a new record for a PT  

3. Create a new record for the Client, which saves under PT name which they provide, but it will create a new PT  

**Where I am stuck/What I’ve tried**

I simply don’t understand how to query the realtimeDB for a match on the user’s details, and I can’t find any articles about running a query on realtimeDB.

Does anyone have any suggestions?

---

<div class="post-metadata">

**Author:** ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)\
**Post date:** [June 30, 2020, 9:33am UTC](https://community.thunkable.com/t/realtime-db-parent-child/590669/2 "2020-06-30T09:33:03Z")

</div>

Hey @jamesx - this sounds like a great idea for an app. Have you made much progress with it?

> [@jamesx](#):
>
> Create a new record for the Client, which saves under PT name which they provide,

It sounds like this could be one area where errors might occur. Have you considered using a ListViewer to show a set list of personal trainers?

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:25am UTC](https://community.thunkable.com/t/realtime-db-parent-child/590669/3 "2024-11-08T11:25:17Z")

</div>


