1 00:00:00,120 --> 00:00:04,680 In this lecture, we're going to briefly discuss two terms that you'll hear often. 2 00:00:04,950 --> 00:00:07,710 I mentioned them a lot in the past few lectures. 3 00:00:07,920 --> 00:00:10,830 I'm talking about references and snapshots. 4 00:00:11,100 --> 00:00:16,020 I frequently get asked by students what the differences are because they seem similar. 5 00:00:16,470 --> 00:00:18,540 Let's talk about them independently. 6 00:00:19,080 --> 00:00:20,580 Starting with references. 7 00:00:20,760 --> 00:00:24,810 A reference is an object pointing to a location in your application. 8 00:00:25,140 --> 00:00:32,400 So far, we've learned we can create references to either the database or storage by pointing to a location 9 00:00:32,400 --> 00:00:37,980 in the application, we can perform operations such as reading and writing to that location. 10 00:00:38,280 --> 00:00:43,800 We use references to upload a file to the storage and add data to the database. 11 00:00:44,400 --> 00:00:47,070 References can create other references. 12 00:00:47,370 --> 00:00:50,910 This behavior allows you to manage multiple locations. 13 00:00:51,390 --> 00:00:53,940 Next, let's talk about snapshots. 14 00:00:54,180 --> 00:00:58,920 Snapshots are objects that are a copy of a location in your application. 15 00:00:59,310 --> 00:01:01,470 They're read only and are immutable. 16 00:01:01,740 --> 00:01:04,110 Immutable means they can't be updated. 17 00:01:04,379 --> 00:01:10,410 If you were to attempt to update a snapshot, those changes wouldn't be reflected in Firebase. 18 00:01:10,950 --> 00:01:17,190 Whenever we make a change to the application, it's typical for Firebase to respond with a snapshot. 19 00:01:17,520 --> 00:01:22,260 One example of a snapshot was when we initiated the upload to Firebase. 20 00:01:22,560 --> 00:01:26,370 We were constantly fed snapshots of the upload process. 21 00:01:26,910 --> 00:01:32,190 In summary, references and snapshots allow you to read the data in Firebase. 22 00:01:32,520 --> 00:01:36,660 References can be used to manipulate the data in your application. 23 00:01:36,990 --> 00:01:40,260 However, snapshots are read only objects. 24 00:01:40,500 --> 00:01:42,510 This makes them memory efficient. 25 00:01:42,750 --> 00:01:46,500 It's the primary reasons why Firebase has snapshots. 26 00:01:46,800 --> 00:01:52,800 You don't always want to interact with Firebase snapshots make your application more lightweight. 27 00:01:53,100 --> 00:01:56,790 As a result, this makes your application run faster. 28 00:01:57,360 --> 00:02:03,630 One last point I want to make is that snapshots are usually returned whenever you listen to changes 29 00:02:03,630 --> 00:02:04,740 using a reference. 30 00:02:05,070 --> 00:02:07,530 You can't create a snapshot directly. 31 00:02:07,860 --> 00:02:10,350 It's created for you during events. 32 00:02:10,889 --> 00:02:15,300 Hopefully, this makes things a little clearer when reading the documentation. 33 00:02:15,570 --> 00:02:18,210 You'll find both words thrown around a lot. 34 00:02:18,480 --> 00:02:21,330 Knowing the difference will make development easier.