Firebase Data Structure
When a new Firebase is created, it is assigned its own unique hostname. For example, if you were to create a Firebase for your SampleChat application, it could live at:
Every piece of data inside your Firebase is addressable by URL. For example, here's a depiction of a SampleChat Firebase with a title and two users:
We refer to these URLs that point to data as locations. Firebase locations can store strings, numbers, booleans, or nested children.
Nested children allow you to structure your data hierarchically. For instance, SampleChat has a list of users, which are located at:
The data for users 'fred' and 'jack' is stored at these nested locations:
In this example, 'fred' and 'jack' are said to be children of 'users', and 'users' is said to be the parent of 'fred' and 'jack'. Note that Firebase locations can contain either data (a string, number, or boolean) or children, but not both.
Locations for data can nest as deeply as you like. For example, the last name for user 'fred' is located at:
When creating a new nested Firebase location, any parents which don't currently exist will be automatically created. If you want to add another user, you can set the following path to the string 'Mike' and the parent locations '/users/mike' and '/users/mike/name' will be automatically created.
If you remove the value for 'first' which you just set, the parents (who now contain no children with data) will be automatically removed and our Firebase will be the same as it was before adding the new user.
Accessing Firebase Data
Easy data accessibility is a core tenet of Firebase. Data at a Firebase location can be accessed in four different ways:
From our REST API. We provide a full-featured REST API, so that you can read and write your data using any device capable of sending HTTPS requests.
From a library or service with Firebase integration. We provide official integrations for AngularJS, BackboneJS, and EmberJS. We have partnerships to integrate Firebase with various services and we have a lively community who has written Firebase utilies for many languages and frameworks.
From a web browser. You can open any Firebase URL in a web browser to see a live view of its data and the changes that are occurring in real-time. You can create and edit data right from your browser.