Firebase Realtime Database JSON tree
One JSON tree: keys, paths and nested values.
What it explains and when it is useful
Firebase Realtime Database stores all data as one large JSON tree. Every value has a path made of keys from the root, such as /roomStatus/P5/state. Apps listen to a path and receive updates in real time.
When to use it: Solutions that use Firebase Realtime Database, typically for live data: status boards, chat, multiplayer game state, presence.
Worked example
Illustrative: PracticePal is a fictional project used throughout this guide.
Alternative scenario. A live room-status board on screens outside the practice rooms, which updates the moment a student checks in. Realtime Database suits this because the screens listen to one small branch.
Scroll sideways to see the whole diagram.
The same data as JSON:
{
"roomStatus": {
"P1": { "state": "free", "until": 1793682000000 },
"P5": { "state": "occupied", "bookingId": "b2291", "checkedInAt": 1793680500000 }
},
"displays": { "corridor-1": { "online": true, "rooms": { "P1": true, "P5": true } } },
"checkins": { "b2291": { "student": "u381", "at": 1793680500000 } }
}Notation and legend
| Symbol or part | Meaning |
|---|---|
| Rounded box | A key with children (a branch) |
| Square box | A leaf: key and value |
| Lines | Nesting: each step adds a key to the path |
| Path | /key/key/key identifies one value |
| Numbers like 1793680500000 | Timestamps in milliseconds (Firebase convention) |
Design decisions it communicates
A diagram earns marks when you explain the decisions it shows. In PracticePal's documentation these would each be one sentence:
- The tree is kept shallow: each display listens to /roomStatus only, not the whole database.
- Rooms a display shows are stored as keys with true values, which is the Realtime Database way to store a set.
- Check-ins are keyed by booking ID so a duplicate check-in overwrites rather than adds.
Common mistakes
- Deep nesting, so reading one value downloads a huge branch.
- Arrays with numeric indexes instead of keyed objects.
- Drawing collections and documents (that is Firestore).
Checklist for your own version
Ticks are saved in this browser only, so you can use the list while you draft.