1 00:00:02,410 --> 00:00:03,490 So we're almost done, 2 00:00:03,500 --> 00:00:04,020 no worries, 3 00:00:04,120 --> 00:00:06,090 it's soon time to get our hands dirty. 4 00:00:06,100 --> 00:00:11,050 Now let me quickly give you an overview over how exactly you will work with mongodb and what 5 00:00:11,050 --> 00:00:11,670 mongodb 6 00:00:11,680 --> 00:00:17,110 exactly does behind the scenes. So we can generally differentiate between the application, 7 00:00:17,110 --> 00:00:20,970 so let's say your node application you are creating and the data layer. 8 00:00:21,130 --> 00:00:25,390 Now in your application, you will have some frontend that can be a single page application, that can 9 00:00:25,390 --> 00:00:31,040 be a mobile app, that can be the views your level or your node app renders. 10 00:00:31,090 --> 00:00:35,530 You'll then have a backend, your server where you have your server side logic and then you have your 11 00:00:35,530 --> 00:00:36,140 data layer, 12 00:00:36,160 --> 00:00:42,070 so you have the database, the data storage, the files on a file system which hold your data in the end. You 13 00:00:42,070 --> 00:00:47,630 have the mongodb server and you have on the backend server where you will write your code, 14 00:00:47,710 --> 00:00:51,040 you have these drivers for the different languages. 15 00:00:51,040 --> 00:00:55,750 Now the drivers will interact with the mongodb server, the mongodb server is what we started with 16 00:00:55,750 --> 00:00:56,730 the mongod command 17 00:00:56,740 --> 00:01:03,280 by the way. Now the mongodb server will actually not directly write the data into files but talk to 18 00:01:03,280 --> 00:01:08,380 a so-called storage engine which you could replace with your favorite storage engine 19 00:01:08,470 --> 00:01:14,950 but the default one called Wired Tiger is actually an awesome storage engine which allows you to efficiently 20 00:01:14,950 --> 00:01:17,910 work with your data, store it efficiently and so on. 21 00:01:18,100 --> 00:01:23,590 So the mongodb basically gets the query from your driver or from your shell and then just 22 00:01:23,600 --> 00:01:29,560 knows I want to insert something and basically forwards that information after doing some other things to 23 00:01:29,650 --> 00:01:34,070 the storage engine and the storage engine then stores it in files in the end. 24 00:01:34,360 --> 00:01:38,980 And instead of the drivers, you can of course also use the mongo shell, there you can also write all the 25 00:01:39,070 --> 00:01:44,340 queries and as you will also see in this course, you would also use the mongo shell as a general playground 26 00:01:44,580 --> 00:01:50,200 and also for administrating your server because that is not something your app will do if you have to 27 00:01:50,800 --> 00:01:56,320 configure something, you would do this as an administrator from your company network through that shell which 28 00:01:56,320 --> 00:01:59,840 is your direct access to the mongodb server. 29 00:01:59,870 --> 00:02:05,750 Now if we have a closer look at that data layer with the server, the storage engine and the file system, then 30 00:02:05,750 --> 00:02:11,870 we actually have to differentiate between writing and reading from files which is a bit slower and writing 31 00:02:11,900 --> 00:02:14,070 and reading from memory which is faster. 32 00:02:14,210 --> 00:02:16,580 The storage engine actually does both, 33 00:02:16,670 --> 00:02:23,210 it loads a chunk of data into memory and manages that such that the data you often use is in memory of 34 00:02:23,210 --> 00:02:24,020 possible, 35 00:02:24,020 --> 00:02:27,740 it also writes data in memory at first so that this is really fast 36 00:02:27,740 --> 00:02:33,410 but then of course it also goes ahead and stores data in the database files and I will dive a little 37 00:02:33,410 --> 00:02:35,060 deeper into that later in the course 38 00:02:35,150 --> 00:02:40,550 but in general, you need to be aware that you always talk to the mongodb server and behind that server, 39 00:02:40,640 --> 00:02:46,210 the server talks to the storage engine which manages your data and stores it in files 40 00:02:46,220 --> 00:02:52,760 in the end but also in memory in between so that you can work with the data in a very fast way. 41 00:02:52,760 --> 00:02:56,150 So this is how the mongodb server works behind the scenes you could say.