Structuring data: How to combine data from different firebase list


#1

Hi,

we are designing an appointment system based on Ionic 3 and Firebase. Shortly, we have:

  • A list of appointments with “workers” and “patients” properties
  • A list of users

User will be possible to see a list of associated appointments in a list.

Every item list will show something like this:

 _______________________________________
| Date: 17/3/2017   Patient: Jonh Snow  |
| Start: 13:48      Worker: Ana Stark   |
 ---------------------------------------
 _______________________________________
| Date: 15/3/2017   Patient: Jonh Snow  |
| Start: 22:48      Worker: Ana Stark   |
 ---------------------------------------

[ ... more items in list ... ]

For worker and patient name, we should store plain text or a key reference to user list? How we should structure the firebase appointment list in terms of scalability, performance and updates?

If we would use the second approach, How can I get data and combine from two diferents nodes with Ionic without performance issues?

This is our first approach with uid and plain text names:

{
  "appointments": {
    "appointmentkey1": {
      "start": "1508919619",
      "end": "1508959219",
      "worker": {
        "uid": "userkey1",
        "name": "Ana Stark"
      },
      "patient": {
        "uid": "userkey2",
        "name": "Jonh Snow"
      }
    },
    "appointmentkey2": {
      "start": "1508914617",
      "end": "1508912234",
      "worker": {
        "uid": "userkey1",
        "name": "Ana Stark"
      },
      "patient": {
        "uid": "userkey2",
        "name": "Jonh Snow"
      }
    }

    [...]

  }
}

This is the second approach only with uid key:

{
  "appointments": {
    "appointmentkey1": {
      "start": "1508919619",
      "end": "1508959219",
      "worker": "userkey1",
      "patient": "userkey2"
    },
    "appointmentkey2": {
      "start": "1508914617",
      "end": "1508912234",
      "worker": "userkey1",
      "patient": "userkey2"
    }
  }
}

User list would be the same for both:

{
  "users": {
    "userkey1": {
      "name": "Ana Stark",
      "birthday": "1508959219",
      "address": "north"
    },
    "userkey2": {
      "name": "Jonh Snow",
      "birthday": "1508953219",
      "address": "south"
    }
  }
}

Thanks in advance for your suggests