In this lecture, we're going to briefly discuss two terms that you'll hear often.
I mentioned them a lot in the past few lectures.
I'm talking about references and snapshots.
I frequently get asked by students what the differences are because they seem similar.
Let's talk about them independently.
Starting with references.
A reference is an object pointing to a location in your application.
So far, we've learned we can create references to either the database or storage by pointing to a location
in the application, we can perform operations such as reading and writing to that location.
We use references to upload a file to the storage and add data to the database.
References can create other references.
This behavior allows you to manage multiple locations.
Next, let's talk about snapshots.
Snapshots are objects that are a copy of a location in your application.
They're read only and are immutable.
Immutable means they can't be updated.
If you were to attempt to update a snapshot, those changes wouldn't be reflected in Firebase.
Whenever we make a change to the application, it's typical for Firebase to respond with a snapshot.
One example of a snapshot was when we initiated the upload to Firebase.
We were constantly fed snapshots of the upload process.
In summary, references and snapshots allow you to read the data in Firebase.
References can be used to manipulate the data in your application.
However, snapshots are read only objects.
This makes them memory efficient.
It's the primary reasons why Firebase has snapshots.
You don't always want to interact with Firebase snapshots make your application more lightweight.
As a result, this makes your application run faster.
One last point I want to make is that snapshots are usually returned whenever you listen to changes
using a reference.
You can't create a snapshot directly.
It's created for you during events.
Hopefully, this makes things a little clearer when reading the documentation.
You'll find both words thrown around a lot.
Knowing the difference will make development easier.