MongoDB for Developers with Python Transcripts
Chapter: High-performance MongoDB
Lecture: Creating the big DB

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Here we are in the github repository for this course
0:04 and notice we have this data section
0:06 and in here I have this thing called dealership db 250 K
0:09 that is this data that I just talked about,
0:12 with the 250 thousand cars, 100 thousand owners, that sort of thing.
0:16 So I'm going to put that over here on the desktop and unzip it
0:21 and if we look in here, you'll see that there's a cars collection and an owners collection,
0:29 and I don't believe we've spoken about how to get this data into MongoDB,
0:33 so let's go over here and I'll use RoboMongo,
0:37 notice we have these two dealership things that I have been playing with
0:42 and I want to create one called like test dealership or something to that effect.
0:46 We're going to restore this— how do we do that,
0:51 we'll go like this, we'll say mongorestore
0:55 and this is the way that we get this exported data imported into MongoDB,
1:00 now, the first thing you have to ask yourself is this additive to the database,
1:05 if it exists do you want to also insert this,
1:07 or do you want to have this be the database and replace anything it exists,
1:11 we want this one to replace existing data
1:14 so I'll say --drop and then I need to tell it what database
1:18 so I'll say db and I could say what you should say is this dealership,
1:23 but just because I don't want to wipe away what I currently have,
1:28 I'll say dealership example, but the code that you're going to run
1:31 expects the name of the database to be just a dealership;
1:34 and then I need to give it the folder that it's going to work from,
1:37 so I am just going to give it this folder like so, all right.
1:41 So mongorestore, drop to replace the data -- db to name it, and then the location,
1:46 we hit go, and it's going to go cranking away on this
1:50 and you can see it's inserting, inserting and done,
1:53 that was really fast for like close to 1.5 million records.
1:57 All right, so let's go over here and refresh
2:00 and here's our example and we can see that we have our collection,
2:03 here's our cars and we could just ask how many cars are there.
2:07 Notice, there is that many, and if we change this to owners,
2:11 remember you can also write it like this, owners like this,
2:16 Now notice, I think the restore data we got here,
2:19 you want to drop this index right here, I have it only have the id indexes, ok
2:26 so that's this example I just restored,
2:28 we're going to work with something you can imagine is exactly the same.
2:33 So we're going to work with this dealership code
2:36 but the way it got there, I'll show you the app I used to originally create it,
2:39 and then I just restored it using mongorestore just as I showed you up here.
2:43 So the way to generate the data that goes into mongorestore, you say mongo dump.