1 00:00:02,180 --> 00:00:07,340 Even though I already showed it in the first course module, it's really important that you understand 2 00:00:07,670 --> 00:00:13,970 how databases collections and documents are related. In a mongodb world, 3 00:00:14,000 --> 00:00:23,090 you have one or more databases on your database server and each database can hold one or more collections, 4 00:00:23,630 --> 00:00:27,720 a collection would be a table in a SQL database. 5 00:00:27,740 --> 00:00:35,630 Now in that collection, you have these documents, multiple documents per collection and the documents 6 00:00:35,660 --> 00:00:38,230 are really the data pieces 7 00:00:38,300 --> 00:00:45,650 you're storing in your database. Now important, when working with mongodb, you will see in this module 8 00:00:45,650 --> 00:00:53,820 already that the databases, the collections and the documents are all automatically created for you, 9 00:00:53,900 --> 00:00:58,000 they are created implicitly when you start working with them, 10 00:00:58,040 --> 00:01:05,720 when you start storing data. That is really convenient, later in the course we'll also learn a way of explicitly 11 00:01:05,840 --> 00:01:10,000 creating new collections which allows you to configure them a bit further 12 00:01:10,160 --> 00:01:15,140 but this is a cool feature which makes getting started super simple. 13 00:01:15,530 --> 00:01:21,620 Now this is the core concept you always should keep in mind and the relation between databases collections 14 00:01:21,620 --> 00:01:23,800 and documents you always should keep in mind. 15 00:01:24,050 --> 00:01:30,060 And now with that out of the way, let's actually bring up that Mongo server again, connect through it through 16 00:01:30,080 --> 00:01:34,630 our shell and again see how we can store data in there 17 00:01:34,690 --> 00:01:37,440 and which kind of data that is. 18 00:01:37,440 --> 00:01:44,120 I'm back in the terminal and I now again want to start my mongodb server, here on Mac, I'll do this with 19 00:01:44,120 --> 00:01:46,370 sudo mongod 20 00:01:46,520 --> 00:01:52,880 and make sure you watch the installation videos in the first course module to get this up and running 21 00:01:52,940 --> 00:01:55,880 on Windows or Mac OS or Linux. 22 00:01:55,880 --> 00:02:00,180 So with that command, I'm prompted to enter my password 23 00:02:00,380 --> 00:02:07,220 and with this entered, it will start up my mongodb server using the wired tiger storage engine. 24 00:02:07,220 --> 00:02:12,080 Now this is the server up and running and you need to keep this process running, so don't close this 25 00:02:12,080 --> 00:02:18,310 window, don't quit this process yet, as you can see it's now waiting for new connections on port 27017 26 00:02:18,330 --> 00:02:19,230 . 27 00:02:19,520 --> 00:02:24,560 By the way if you wanted to use a different port or you're facing issues with this one, you can use a 28 00:02:24,560 --> 00:02:25,550 different port 29 00:02:25,580 --> 00:02:31,880 and now I did quit the server by hitting control and c, you can use a different port by specifying 30 00:02:31,880 --> 00:02:34,680 --port when starting up the server 31 00:02:34,820 --> 00:02:37,750 and then you can for example choose 27018 32 00:02:37,850 --> 00:02:38,990 as a port 33 00:02:39,110 --> 00:02:42,020 and now you see, it would be listening on that. 34 00:02:42,020 --> 00:02:47,390 So that's just a tiny piece of information which can be useful in case you're using that default port 35 00:02:47,570 --> 00:02:49,310 for something else. 36 00:02:49,340 --> 00:02:54,800 So with that up and running, let's keep that up and running and open a new additional window in the terminal 37 00:02:55,460 --> 00:02:59,250 and in there, you can now run Mongo without a d at the end 38 00:02:59,300 --> 00:03:05,240 to use the mongo shell and automatically connect to the up and running server. 39 00:03:05,240 --> 00:03:11,930 Now here however, I get a connect failed and that happened because by default, it tries to reach the server 40 00:03:11,960 --> 00:03:15,580 on port 27017 which is obviously not the port 41 00:03:15,590 --> 00:03:16,680 I'm running on. 42 00:03:16,850 --> 00:03:23,490 So I can connect by using Mongo --port and then using that port where my server is running 43 00:03:23,510 --> 00:03:29,160 and now you see this did connect successfully. With that we did connect again, 44 00:03:29,330 --> 00:03:33,730 Now you can run cls in here and hit enter to clear the window, 45 00:03:33,730 --> 00:03:39,610 I'm still in the shell here and if I scroll up, I see all the old output, cls just clears the window. 46 00:03:39,830 --> 00:03:44,790 And now we can start running commands again and work with our database.