Building data-driven web apps with Pyramid and SQLAlchemy Transcripts
Chapter: MongoDB edition
Lecture: The (new) data model

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now before we actually go and write the code
0:02 let's just look, really high level, at the data model.
0:04 Here is some reasonable representation
0:07 of what we are doing with SQLAlchemy and SQLite.
0:12 I don't think this is an exact match of what we built
0:14 but it's kind of close.
0:15 Okay, so we've got packages.
0:17 Packages have maintainers.
0:19 This is that normalization table
0:20 and we have users, and then packages have releases
0:24 and things like that, that's the release history.
0:26 They also have operating systems
0:27 programming languages, so on and so on.
0:31 Okay, so if we take this data model and we reimagine it
0:34 in a document database, it gets so much simpler.
0:37 Watch this.
0:38 See all those relationships in all these tables?
0:41 There it is in MongoDB or any document database.
0:44 We have users, we have packages, we have release history
0:47 and we have downloads.
0:48 We didn't really model that very much in our example
0:50 but we do have that in SQLAlchemy as well.
0:52 This is easier to wrap your head around, right?
0:54 Much easier.
0:56 However, when you crack open these little boxes
0:59 like you look inside packages, it's more complicated
1:01 because we have more stuff in there.
1:02 All those relationships in that data is still there
1:04 so if we dig in, packages are pretty straightforward
1:07 but the release history, each release
1:10 at least in this little model here
1:12 could have a different set of operating systems
1:14 it works with, a different set of programming languages
1:16 and then if you look at packages
1:19 it has that maintainer foreign key relationships
1:22 so instead of having a normalization table there
1:24 we just embed that within packages.
1:26 So we're going to take something kind of like this
1:29 and build it in MongoDB in our application
1:32 to replace, entirely, our SQLite, SQLAlchemy based database.