Real Time Database

Firebase Real-time database overview

  • Cloud-hosted database

  • NoSQL database; data is stored as JSON

  • Changes made to the database are automatically synchronized for any other computer/phone (i.e. client) that is viewing data from the database

  • Real-time database documentation can be found here


Data Structure

  • Firebase’s real-time database is structured like a JSON tree (think root and branches)

  • Data stored in a JSON tree is hierarchical (parent/child)

  • Propertie names in the JSON tree can be used as keys (i.e. unique identifiers)

{
  "users": {
    "alovelace": {
      "name": "Ada Lovelace",
      "contacts": { "ghopper": true },
    },
    "ghopper": { ... },
    "eclarke": { ... }
  }
}

In the example above, we have a object that contains a list of users. Each user is represented as an object that has a property name or key. alovelace is the key that is tied to the object containing this user’s name and contacts.

  • keys must be unique