Database Connection: Firebase Flashcards
What services are offered by firebase
Firebase is a mobile platform that offers services that include: Analytics, Authentication, Realtime Database, Cloud
Firestore, Cloud Storage for Firebase, Cloud Functions for
Firebase, Firebase ML, Crashlytics, Performance Monitoring, Test Lab, App Distribution, Cloud Messaging, In-App Messaging, Remote Config, Dynamic Links, and AdMob.
Give a brief history of firebase
● Firebase started off as Envolve, a startup by James Tamplin and Andrew Lee in 2011.
● Envolve initially specialized as an API to integrate online chat functionality.
● After realization by the owners that Firebase was being used by
developers to pass application data, Firebase was started as a separate company in the same year and released in April to the public.
● The initial service Firebase offered was Realtime Database (a functionality that Firebase is mostly popular for among developers), but eventually, it
accommodated more services.
● Google acquire Firebase in October 2014, and merged it with Divshot, another company the bought in October 2015. Divshot specialized in HTML5 web-hosting.
Describe firebase realtime database
● Firebase’s realtime database is a cloud-hosted database that stores and sync’s data using NoSQL.
● The data stored remains available even when the
application is offline.
● Data is stored as JSON and synchronized in realtime to every connected client.
What are the capabilities of the firebase realtime database
● It is realtime
● It works even while the app is offline as it persists the data to disk, ensuring synchronization
happens once connectivity is reestablished
● Client devices can access the database with no need of using an application server
● It can scale across multiple databases (monetary subscription required)
What is the implementation path?
– Integrate the Firebase Realtime Database SDKs
– Create Realtime Database references
– Set Data and Listen for Changes
– Enable Offline Persistence
– Secure your data using Firebase Realtime Database Security Rules
What are the steps to connect your Android Application to Firebase
– Create a database
– Add the Realtime Database SDK to your application
– Configure the Realtime Database Rules
– Perform CRUD functionalities to your application
What are the different starting modes for Firebase Security rules
– Test mode – recommended for getting started with mobile and web client (not so secure as anyone can read and overwrite your data)
– Locked mode – Denies all reads and writes from mobile and web clients
What are the possible URLs when creating the databases
DATABASE_NAME.firebaseio.com (for databases in us-central1)
DATABASE_NAME.REGION.firebasedatabase.app (for databases in all other locations)
Describe and illustrate with code how to Add the Realtime Database SDK to your Application
● In your module (app-level) Gradle file (usually <project>/<appmodule>/build.gradle), add the dependency for the Realtime Database
Android library.
● Google recommends using the Firebase Android BoM to control library versioning and also use compatible versions of Firebase Android libraries.</appmodule></project>
*See page 9
Describe the stage for configuring Realtime Database
Rules
● The Realtime Database provides a declarative rules language that allows you to define:
– how your data should be structured
– how it should be indexed, and
– when your data can be read from and written to.
Describe and illustrate with code how to write to a realtime database
Retrieve an instance of your database using getInstance() and reference the location you want
to write to.
*See page 11
Describe and illustrate with code how to read from a realtime database
● To make your app data update in realtime, you should add a ValueEventListener to the
reference you just created.
● The onDataChange() method in this class is triggered once when the listener is attached
and again every time the data changes, including the children.
*See page 13