Skip to content

Commit 486a5cd

Browse files
committed
Full course transcripts.
1 parent 097b044 commit 486a5cd

File tree

32 files changed

+2851
-0
lines changed

32 files changed

+2851
-0
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
00:01 Hello and welcome to MongoDB Quick Start with Python.
2+
00:05 MongoDB is one of the most popular
3+
00:07 and exciting database technologies around.
4+
00:09 Python is one of the most popular
5+
00:11 and fastest growing language there is
6+
00:12 and these two technologies work great together
7+
00:15 and that's exactly what this course is about.
8+
00:17 We're going to quickly get started with MongoDB,
9+
00:20 write some code against it,
10+
00:22 and build some realistic applications.
11+
00:24 The goal with this class is to teach you MongoDB.
12+
00:27 We assume you know a little bit of Python
13+
00:29 but you'll of course pick some things up along the way
14+
00:31 if you don't know it already, and really,
15+
00:33 we want to get you going quick, hence the name, Quick Start.
16+
00:36 Let's get started by talking about
17+
00:38 what we're going to cover in this course.
18+
00:39 We're going to focus on three main things.
19+
00:41 We're going to start with why do you care about
20+
00:44 NoSQL and Document Databases.
21+
00:46 How do document databases make working with schemas easier,
22+
00:50 modeling data easier, as well as add performance
23+
00:54 and flexibility to our applications.
24+
00:55 We're going to talk about modeling specifically,
25+
00:58 'cause it is one of the things that is
26+
00:59 pretty challenging about document databases.
27+
01:02 If you come from a relational database world,
28+
01:04 you probably know about third normal form.
29+
01:06 This is a way to carefully and
30+
01:08 more structured way to plan out how you model your data.
31+
01:11 In document databases, you don't really have that.
32+
01:13 There's a lot more sort of flexibility
33+
01:16 in how you design things.
34+
01:18 This is great for you once you understand it
35+
01:20 and get really good at it, but it's challenging to know
36+
01:22 how to model things when you get started
37+
01:24 because there's so much flexibility
38+
01:26 and it's kind of open-ended.
39+
01:27 It feels a little more like art than science, in some sense.
40+
01:30 So we're going to focus specifically on
41+
01:32 techniques and trade offs, and some guidelines
42+
01:35 I have to come up with to help you be successful
43+
01:38 modeling your data with document databases such as MongoDB.
44+
01:42 Then we're going to start writing code for real.
45+
01:44 We're going to use a Mongo ODM, Object Document Mapper.
46+
01:49 Think of SQL Alchemy but for document databases.
47+
01:51 They're called MongoEngine, and we're going to use that
48+
01:54 to create some classes to model our data,
49+
01:57 and map those classes to and from MongoDB
50+
01:59 and use that as the foundation of our application.
51+
02:02 Speaking of applications,
52+
02:03 what are we going to build in this class?
53+
02:05 Well, we're going to build an AirBnB clone but for snakes.
54+
02:09 Okay, so we're going to build Snake BnB
55+
02:11 and this allows you, when you're traveling with your snake,
56+
02:14 your pet snake, you don't want it to have to
57+
02:17 live out in the car or something like that.
58+
02:19 You want to get it a cage that it can live in,
59+
02:21 a proper snake cage where it'll be happy.
60+
02:23 There'll be owners of cages
61+
02:25 who can put their cages up for rent,
62+
02:27 and snake owners, pet owners
63+
02:29 who want to travel with their pets and
64+
02:31 have their pet have a place to stay.
65+
02:33 We're going to create this sort of silly
66+
02:35 AirBnB knockoff clone, but we're going to model
67+
02:37 many of the operations you would see
68+
02:39 in real AirBnB on our application here
69+
02:42 so it's going to be pretty rich in terms of data.
70+
02:44 As far as tools go, well of course,
71+
02:45 we're going to talk about MongoDB, right.
72+
02:47 That's the database we're using,
73+
02:49 but you're also going to learn some other things
74+
02:50 that are pretty awesome in the course.
75+
02:52 We're going to talk about MongoEngine.
76+
02:54 This is the primary library
77+
02:55 we're going to use to talk to MongoDB.
78+
02:57 It's built upon another one that's very popular
79+
03:00 that has sort of the lowest level
80+
03:01 official way to talk to MongoDB called PyMongo,
81+
03:04 so you might see a little bit of
82+
03:05 both of those actually in the course.
83+
03:07 We're going to use what I think is
84+
03:08 the best tool for accessing MongoDB,
85+
03:11 something that used to be called Robomongo
86+
03:14 but now it's called Robo 3T,
87+
03:16 'cause it was acquired by a company called 3T.
88+
03:18 This is part command line,
89+
03:20 part GUI way to interact with MongoDB,
90+
03:23 and it's beautiful, and free open source, it's great.
91+
03:26 Also, we're going to use PyCharm for our Python code.
92+
03:29 You don't have to use PyCharm for this course,
93+
03:31 but you'll see me using it, and I think you'll see
94+
03:33 a lot of benefits as we go.
95+
03:36 Speaking of me, who am I anyway?
96+
03:37 Who is this voice that you're listening to?
97+
03:39 Hi, my name is Michael Kennedy.
98+
03:40 You can find me on Twitter at @mkennedy.
99+
03:43 What makes me qualified to teach this course?
100+
03:45 Well, first of all, I host the most popular Python podcast
101+
03:48 called Talk Python to Me, and I've interviewed
102+
03:51 many, many people, including some of the folks from MongoDB,
103+
03:54 the company as well as authors who've written about
104+
03:57 MongoDB design patterns and things like that,
105+
03:59 so I've had a lot of experience
106+
04:00 working with people from Python and MongoDB.
107+
04:03 I've created the Talk Python Training Company
108+
04:06 and written many Python courses
109+
04:08 and MongoDB courses there as well.
110+
04:10 And also, I am part of the MongoDB Masters Program.
111+
04:14 This is a group of about 35 external community members
112+
04:18 who give advice back to MongoDB,
113+
04:21 and I've been part of this for many years,
114+
04:23 worked closely with the folks inside MongoDB over the years.
115+
04:26 So this is what you have in store for you,
116+
04:28 lots of awesome MongoDB and Python.
117+
04:30 I hope you're excited.
118+
04:31 Let's get right to it.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
00:01 Let's begin by looking at why you might choose MongoDB
2+
00:05 over other NoSQL databases, other document databases,
3+
00:09 or even other relational databases.
4+
00:12 I'm sure you've heard of MongoDB.
5+
00:14 That's why you're taking this course.
6+
00:15 But how popular is it relative to other databases?
7+
00:19 Is it really the right choice?
8+
00:20 Well, let's look at some data from 2017.
9+
00:23 If you compare MongoDB against other NoSQL databases,
10+
00:27 Cassandra, CouchDB, RavenDB, things like that.
11+
00:31 You will find one of these databases is unlike the others.
12+
00:34 Look at that, that's incredible,
13+
00:36 how much more popular MongoDB is over these.
14+
00:39 It's not just the popularity that it's five,
15+
00:42 10 times, maybe 50 times more popular than RavenDB.
16+
00:46 That's great.
17+
00:47 That's very important.
18+
00:47 But also, the trend.
19+
00:50 These others are either flat or turning downwards.
20+
00:51 And this is, besides the little blip here,
21+
00:54 based on probably the end of the year numbers
22+
00:57 or something like that.
23+
00:58 At the end of the data, this is a really big deal.
24+
01:01 This is incredible how much growth is here,
25+
01:04 and it's still going up.
26+
01:05 MongoDB is really, really popular
27+
01:07 in terms of a database that people are using.
28+
01:11 And that's great because that means it's well-tested.
29+
01:14 When we get the section a little bit later,
30+
01:16 we'll look at some of the users of MongoDB.
31+
01:18 But it's really important
32+
01:19 that there are some heavy workloads put onto these databases
33+
01:23 that you're going to depend upon.
34+
01:24 And if it can take what those people are doing,
35+
01:26 surely, it can take what you have to throw at it as well.
36+
01:29 Now, MongoDB is also loved.
37+
01:31 If you look at Stack Overflow,
38+
01:33 at their 2017 Developer's Survey,
39+
01:36 and you look at the most loved databases:
40+
01:38 these are databases that the developers are using currently
41+
01:43 and how they feel about it.
42+
01:44 We see MongoDB ranks right near the top.
43+
01:46 So, definitely 55% of the people
44+
01:49 who are using MongoDB love it compared to
45+
01:51 say SQLite or Cassandra.
46+
01:54 So, this is pretty good.
47+
01:55 But what's even more interesting
48+
01:56 is that it's the most wanted database.
49+
01:59 These are technologies that you're not currently
50+
02:01 able to work with but you would like to.
51+
02:03 So, there are tons of people that want to work with MongoDB
52+
02:05 but for whatever reason, they've got some Legacy system
53+
02:07 built on MySQL or whatever, they don't get the chance to.
54+
02:11 All these pieces of data tell you
55+
02:13 MongoDB is a really good technology to have
56+
02:15 in your tool belt.
57+
02:16 And it's easy to get ahold of.
58+
02:18 MongoDB is open source and it's free.
59+
02:20 You can just go to github.com/mongodb/mongo
60+
02:23 and clone it and it's right there.
61+
02:25 You can see it has 11,000 stars, 3,000 forks.
62+
02:29 And this screenshot I took here was updated two hours ago.
63+
02:32 It's under very, very active development.
64+
02:34 It's a live and vibrant project.
65+
02:36 Finally, if you actually want to get MongoDB,
66+
02:38 don't go to GitHub.
67+
02:40 GitHub is cool, it's great.
68+
02:41 You have the source but don't go there.
69+
02:42 What you really want to do is you want
70+
02:43 to go to mongodb.com/download-center.
71+
02:47 Or just go to mongodb.com and click Download.
72+
02:49 It'll take you here.
73+
02:50 And you download here, you get it as binary.
74+
02:53 So, if you're on Mac,
75+
02:54 I recommend you use Homebrew to install it.
76+
02:56 But you can also download a tarball.
77+
02:58 If you're on Windows, get the MSI.
78+
03:00 And on Linux, you can actually install it
79+
03:02 with aptitude or some package manager like that.
80+
03:05 In this course, we're not going to go into the details
81+
03:07 of setting up MongoDB.
82+
03:08 Just follow the instructions.
83+
03:09 In the full MongoDB course you have,
84+
03:11 we walk through all the steps,
85+
03:12 but we just want to get started.
86+
03:13 This the quick start.
87+
03:14 So, let's keep moving.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
00:00 Let's look at one of these records stored in MongoDB
2+
00:03 to see how document databases work.
3+
00:05 Here we have a JSON record.
4+
00:08 This is actually from one of my courses,
5+
00:10 the Python Jumpstart by Building 10 Apps,
6+
00:12 and this is how I represent it in the database.
7+
00:14 We've got standard columnar type things,
8+
00:17 so we have an ID, we have a title, a course ID,
9+
00:20 duration in seconds, these types of things.
10+
00:22 Now, first of all, you might be wondering,
11+
00:24 wait a minute, JSON database?
12+
00:26 JSON database, is that really efficient?
13+
00:28 Well, probably not.
14+
00:29 What MongoDB actually stores is a binary representation.
15+
00:33 So like a binary tokenized version of this record,
16+
00:37 but they call it BSON,
17+
00:38 because it's like binary JSON.
18+
00:40 But we're humans, we don't read binary, we read text.
19+
00:43 So we're looking at the textual representation.
20+
00:45 So this is not exactly how it gets stored,
21+
00:46 but this is pretty close.
22+
00:47 So we have these regular column type pieces of information,
23+
00:51 ID, title, and so on,
24+
00:53 but we also have this other thing, these lectures.
25+
00:55 Now these lectures are in this chapter represented
26+
00:58 by this record from this course,
27+
00:59 and notice the bracket in JavaScript,
28+
01:02 which basically this
29+
01:03 means that it is an array.
30+
01:06 And the array contains a bunch of sub-objects.
31+
01:08 So this is really interesting.
32+
01:09 Instead of just having a chapter table
33+
01:12 and a lecture table,
34+
01:13 and doing a join or something like that,
35+
01:15 a form key relationship,
36+
01:16 we're actually putting the lectures inside the same record.
37+
01:19 This is pretty interesting.
38+
01:21 When you look at it like this,
39+
01:22 you can imagine that this is like a precomputed join.
40+
01:25 If I do a query for the lecture,
41+
01:28 say, given ID1001,
42+
01:30 and I get this record back, it already has the lectures.
43+
01:33 I don't have to make another round trip
44+
01:35 to the database to get them.
45+
01:36 I don't have to do a join against several tables
46+
01:39 in that original query.
47+
01:40 It's literally a primary key query
48+
01:42 against an indexed primary key and is insanely fast,
49+
01:45 yet it already comes back
50+
01:46 with all this extra information.
51+
01:48 So this is really cool.
52+
01:49 If I get the chapter, I have the lectures, great.
53+
01:51 But, you might be wondering well, really,
54+
01:54 what if I need to ask the question in reverse?
55+
01:57 Like, fundamentally, if I need to get at lecture 10106,
56+
02:02 will I be able to query MongoDB quickly and efficiently
57+
02:06 to get that lecture?
58+
02:08 And it turns out, the answer is yes.
59+
02:10 And that's why document databases are awesome.
60+
02:12 It's not just some nested blob stored in
61+
02:15 the original record,
62+
02:16 you can, as part of the query language
63+
02:18 and part of indexes, traverse these hierarchies
64+
02:21 in very, very rich and powerful ways.
65+
02:23 We don't lose very much query capability
66+
02:26 just by putting lectures in this one record.
67+
02:29 So this is really neat,
68+
02:30 and this is sort of the foundational,
69+
02:32 most important take away from document databases.
70+
02:35 We store them in these flexible JSON type of objects,
71+
02:38 and we can nest additional things like lists of numbers,
72+
02:43 or even subdocuments, as we have in this case.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
00:02 Before we move on,
2+
00:03 let's take a moment and look at who uses MongoDB.
3+
00:06 Programming languages and databases
4+
00:09 and technologies aren't necessarily popularity contests.
5+
00:13 Just because something's popular
6+
00:14 doesn't necessarily mean that it's great:
7+
00:17 evidence, PHP for example,
8+
00:19 or VB, or something like this.
9+
00:20 Technologies are popular and some of them are great,
10+
00:23 and sometimes great technologies are popular.
11+
00:25 There are some important things that come along
12+
00:28 with being popular and used by big important companies.
13+
00:32 That means these things are durable,
14+
00:34 tested, and have really been through the ringer.
15+
00:36 MongoDB has been used by some really big customers
16+
00:40 and some really interesting use cases.
17+
00:42 I know some of the biggest ones
18+
00:44 are not on this page even.
19+
00:46 They're not listed here.
20+
00:46 So we're going to take a quick tour of a couple of customers
21+
00:49 who are using MongoDB
22+
00:50 and we'll look at how they're using it.
23+
00:52 Okay, so the first one that I want to look at,
24+
00:54 scroll down here, you can see names that you might know.
25+
00:56 Some cool stuff here.
26+
00:57 Let's check out Royal Bank of Scotland.
27+
00:58 Banks are supposed to be conservative.
28+
01:01 Things like this, they probably wouldn't use weird
29+
01:03 NoSQL document databases,
30+
01:04 they're going to stick to their traditional Oracle
31+
01:06 or single server, or whatever.
32+
01:07 Well, if we look at Royal Bank of Scotland,
33+
01:09 they're using MongoDB
34+
01:11 to support a global enterprise data service
35+
01:14 underpinning several core trading systems.
36+
01:16 If you're a bank, the core trading systems are
37+
01:18 pretty much the center of the universe, right?
38+
01:22 So the fact that they're driving that with Mongo,
39+
01:23 and that's high performance,
40+
01:25 and it's doing that for them,
41+
01:26 that's really awesome.
42+
01:26 Let's check out Expedia.
43+
01:27 Expedia, they have their app built on MongoDB,
44+
01:30 and they are supporting millions of customers
45+
01:32 shopping for flights, hotels, cars, things like that.
46+
01:37 That's pretty awesome.
47+
01:38 Let's check out another one down here.
48+
01:39 EA, so video games.
49+
01:41 This is the world's best-selling sports game franchise,
50+
01:43 and they rely on MongoDB to scale the millions of players.
51+
01:47 That is really awesome.
52+
01:48 One more, before we move on.
53+
01:49 These guys down here a little farther,
54+
01:52 that's SailThru.
55+
01:54 SailThru is a company that does outbound mail
56+
01:57 and analytics and things like that.
57+
01:58 They are a marketing company
58+
02:01 very much doing tons of email type of stuff, like I said.
59+
02:04 And they have over 40 TB of data
60+
02:06 and a 120 physical, mostly physical, nodes.
61+
02:10 So 120 servers all working, running MongoDB,
62+
02:16 in some giant cluster, which is a pretty awesome use case.
63+
02:20 And, of course, you have things like Shutterfly
64+
02:21 running on MongoDB, Squarespace, on and on.
65+
02:24 There's a ton of cool use cases down here,
66+
02:26 but I think you've got the idea.

0 commit comments

Comments
 (0)