1 00:00:00,210 --> 00:00:06,870 Welcome to the start of a new section and to this start of a new project the task manager project. 2 00:00:06,870 --> 00:00:12,480 Now in this video in particular we're gonna talk about the database we'll be using to store our user 3 00:00:12,480 --> 00:00:15,150 data that is Mongo D.B.. 4 00:00:15,150 --> 00:00:20,970 So for this new project we're gonna have an authentication system and we're going to need a more robust 5 00:00:20,970 --> 00:00:28,370 solution than just storing all of our data in a Jason File like we had done for the notes application. 6 00:00:28,380 --> 00:00:33,900 Now before we dive in and actually explore this database I want to do a little bit of housekeeping. 7 00:00:33,930 --> 00:00:40,230 I'm gonna close all open editors in Visual Studio code and I'm also going to collapse that web server 8 00:00:40,230 --> 00:00:46,020 directory since we're done with that and we're gonna move on to a new project from the terminal. 9 00:00:46,020 --> 00:00:53,490 We can use control C to shut down node mine and I'll use it C D dot dot to navigate out of the web server 10 00:00:53,490 --> 00:00:56,880 folder back to the node course directory. 11 00:00:57,090 --> 00:01:00,270 From here we can use clear to clear the terminal output. 12 00:01:00,270 --> 00:01:04,240 And now we have a nice clean space for starting our new project. 13 00:01:04,380 --> 00:01:08,370 From here we're going to move into the browser and do something similar. 14 00:01:08,370 --> 00:01:12,540 I'm going to close all four tabs related to the weather application. 15 00:01:12,630 --> 00:01:14,080 That was the github tab. 16 00:01:14,100 --> 00:01:20,280 The Heroku tab that our local and production version of the application I can leave open the chrome 17 00:01:20,280 --> 00:01:23,050 inspect tab though in case we need to use that. 18 00:01:23,160 --> 00:01:29,160 And from here we're gonna crack open a new tab and to start we're going to explore the database we'll 19 00:01:29,160 --> 00:01:36,010 be using to store all of our user data that is Mongo D.B. we can find Mongo D.B. on the web. 20 00:01:36,030 --> 00:01:37,860 Over at Mongo D.B.. 21 00:01:37,850 --> 00:01:38,750 Dot com. 22 00:01:38,760 --> 00:01:45,100 Now Mongo D.B. is an open source database and it's also available for old operating systems. 23 00:01:45,120 --> 00:01:50,100 So whether you're running on Windows Mac or Linux you're gonna be able to install the database and get 24 00:01:50,100 --> 00:01:51,390 it running on your machine. 25 00:01:51,660 --> 00:01:56,040 And that's exactly what we'll end up doing in the next couple of videos from there. 26 00:01:56,070 --> 00:02:02,940 We'll be able to use the Mongo D.B. native driver to connect to our database from node j s and we'll 27 00:02:02,940 --> 00:02:07,060 be able to start the process of writing and reading data. 28 00:02:07,060 --> 00:02:14,600 Now Mongo D.B. was originally launched in 2009 which as you'll remember is the same year when no J.S. 29 00:02:14,610 --> 00:02:16,020 was first launched. 30 00:02:16,020 --> 00:02:21,960 Now the timing here is merely coincidental but the no GSK community definitely fell in love with Bongo 31 00:02:21,960 --> 00:02:27,180 D.B. and it became the database of choice for many no J S developers. 32 00:02:27,180 --> 00:02:33,380 Now it's important to note that no J ust isn't exclusive to mongo DB in any way whatsoever. 33 00:02:33,420 --> 00:02:39,990 You can use Mongo D.B. in other programming languages and you can use other databases with no to J S 34 00:02:40,200 --> 00:02:41,710 you could use as an example. 35 00:02:41,730 --> 00:02:47,850 Might ask you well or post graphs with no J yes as well but we have to pick something and Mongo DB is 36 00:02:47,850 --> 00:02:50,520 a great choice for node j s developers. 37 00:02:50,520 --> 00:02:55,880 We'll learn more about why it's a great choice as we actually start to use it in this section. 38 00:02:55,890 --> 00:03:00,810 If you've worked with a database before it's possible you worked with an S Q L database. 39 00:03:00,810 --> 00:03:06,300 This would include a very popular database solutions like my S Q Well and post grass. 40 00:03:06,480 --> 00:03:14,520 Now Mongo D.B. falls under a different category of database called a no ask you l database Eskew L stands 41 00:03:14,520 --> 00:03:22,470 for the Structured Query Language and no less Q L stands for not only structured query language. 42 00:03:22,470 --> 00:03:27,930 Now the actual usage of Mongo D.B. is going to look a bit different than what you'd see if you were 43 00:03:27,930 --> 00:03:34,320 using an ESC You l database but it's going to provide us with a structured way to store and interact 44 00:03:34,380 --> 00:03:35,280 with our data. 45 00:03:35,340 --> 00:03:42,510 Mongo D.B. also provides no J S developers with NPM module that can easily be used to read and write 46 00:03:42,510 --> 00:03:44,000 from the database. 47 00:03:44,010 --> 00:03:49,650 Now to wrap up this video what I want to do is move into a quick visualization that's going to compare 48 00:03:49,650 --> 00:03:52,600 and contrast both Eskew L and no s. 49 00:03:52,600 --> 00:03:59,010 Q L databases at a high level and in the next couple of videos will actually start the process of installing 50 00:03:59,010 --> 00:04:04,170 this on our machine and connecting to it from node j s or this comparison. 51 00:04:04,170 --> 00:04:09,900 We'll put our Eskew El database on the left hand side and we'll put our no Eskew l database in this 52 00:04:09,900 --> 00:04:10,260 case. 53 00:04:10,260 --> 00:04:17,190 Mongo D.B. over here on the right now many of the concepts are identical in both but some are slightly 54 00:04:17,190 --> 00:04:22,740 different or at least have different names and the goal here is for us to build up a vocabulary for 55 00:04:22,740 --> 00:04:29,900 no Eskew well that we can use as we're integrating Mongo D.B. into our node j s applications. 56 00:04:29,910 --> 00:04:31,940 Let's start with an easy comparison. 57 00:04:31,950 --> 00:04:33,770 The concept of a database. 58 00:04:33,780 --> 00:04:40,110 Both have them and with Mongo D.B. we can create as many databases as our application needs and we'll 59 00:04:40,110 --> 00:04:46,410 learn how to do that in just a few videos so we can easily create one database for one application and 60 00:04:46,410 --> 00:04:50,220 then we could create other databases for our other apps. 61 00:04:50,250 --> 00:04:55,740 Now from here we start to talk about exactly how the data is stored and that's where we start to see 62 00:04:55,740 --> 00:05:02,510 some differences between the Eskew El database on the left and know Eskew well database on the right 63 00:05:02,690 --> 00:05:08,660 for the Eskew El database your data is stored in this which is known as a table your database could 64 00:05:08,660 --> 00:05:12,200 have as many tables as you need for your application. 65 00:05:12,200 --> 00:05:18,230 So you might have one table to store your user data and another to store the various tasks that your 66 00:05:18,230 --> 00:05:20,510 users need to complete right here. 67 00:05:20,510 --> 00:05:27,110 Each user has an I.D. a name an email and a password and I have an example user down below. 68 00:05:27,110 --> 00:05:34,010 Now we're also storing data in our no Eskew databases but it looks a bit more like this and I no S Q 69 00:05:34,010 --> 00:05:40,700 L vocabulary it's referred to as a collection you know Eskew l database can have as many collections 70 00:05:40,730 --> 00:05:47,330 as it needs so as with the example from our s fuel database you might have one collection which stores 71 00:05:47,360 --> 00:05:54,500 a list of users in your application and you might have a second collection which stores a list of tasks 72 00:05:54,530 --> 00:05:56,820 that your users need to complete. 73 00:05:56,870 --> 00:06:02,300 Now when it comes to describing the actual data what we're seeing here we have a different set of terms 74 00:06:02,300 --> 00:06:03,520 between the two. 75 00:06:03,590 --> 00:06:11,120 How do we describe the individual items being stored in either the table or the collection in S Q Well 76 00:06:11,180 --> 00:06:13,990 this is known as a row or a record. 77 00:06:14,000 --> 00:06:20,600 So here I could say I have a user's table with a single record meaning that there is one entry inside 78 00:06:20,600 --> 00:06:27,380 of there inside of a no ask you l database we have what are known as documents and you can see a document 79 00:06:27,440 --> 00:06:32,550 right here highlighted in blue documents look a whole lot like Jason. 80 00:06:32,660 --> 00:06:35,880 So we have Rosen records and we have documents. 81 00:06:35,930 --> 00:06:41,090 What about the individual things stored inside of there for at S Q L database. 82 00:06:41,090 --> 00:06:43,070 This is known as a column. 83 00:06:43,160 --> 00:06:51,720 So here I can say I have a user table with four columns I.D. name email and password in a no Eskew l 84 00:06:51,740 --> 00:06:55,950 database like Mongo D.B. these are just known as fields. 85 00:06:56,000 --> 00:07:02,780 So here I could say this document has four fields I d name email and password. 86 00:07:02,780 --> 00:07:09,500 So it's really important to understand the basic vocabulary for a no Eskew l database so we can actually 87 00:07:09,500 --> 00:07:16,370 start to use it and have conversations about Mongo D.B. with all of us being on the same page as to 88 00:07:16,370 --> 00:07:24,260 what a collection is what a document is and what a field is a collection is a list of injuries those 89 00:07:24,260 --> 00:07:31,190 individual entries are referred to as documents and a document can have as many fields as you need your 90 00:07:31,190 --> 00:07:37,460 users collection might have four fields for each user while a different collection for something like 91 00:07:37,460 --> 00:07:43,190 tasks would have a completely different set of fields for each document and we'll learn how to set all 92 00:07:43,190 --> 00:07:48,800 of that up as we progress through the class that's where we're going to stop for this video now that 93 00:07:48,800 --> 00:07:54,710 we have some basic vocab locked down it's time to move on to the next two videos which are going to 94 00:07:54,710 --> 00:08:00,980 be installation videos where we're going to get Mongo D.B. setup there is one installation video for 95 00:08:00,980 --> 00:08:06,680 Mac and Linux and there's a separate one for Windows users let's go ahead and jump right in.