Maeh Maeh - 1 month ago 7
JSON Question

Firebase data structure: Attending school on date

I am currently looking into my first application using Firebase as the backend.

I have 2 models, School and User. Each user can sign up for a date to attend the school, so I also need a Date.

A SQL table would look like this:

schools: id, name


users: id, name, email


schools_users: id, school_id, user_id, date


What would be the proper way of designing this data structure in Firebase?

Answer Source

Since you don't specify any requirements, I suggest starting with the most naive mapping at first:

root
    schools
        1: "name of school1"
        2: "name of school2"
    users:
        1: { "name": "Maeh", "email": "2523229@stackoverflow.com" }
        2: { "name": "Frank", "email": "209103@stackoverflow.com" }
    schools_users:
        1_1: "20141031"
        1_2: "20130102"