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 let's just look, really high level, at the data model. Here is some reasonable representation
0:08 of what we are doing with SQLAlchemy and SQLite. I don't think this is an exact match of what we built but it's kind of close.
0:16 Okay, so we've got packages. Packages have maintainers. This is that normalization table and we have users, and then packages have releases
0:25 and things like that, that's the release history. They also have operating systems programming languages, so on and so on.
0:32 Okay, so if we take this data model and we reimagine it in a document database, it gets so much simpler. Watch this.
0:39 See all those relationships in all these tables? There it is in MongoDB or any document database.
0:45 We have users, we have packages, we have release history and we have downloads. We didn't really model that very much in our example
0:51 but we do have that in SQLAlchemy as well. This is easier to wrap your head around, right? Much easier. However, when you crack open these little boxes
1:00 like you look inside packages, it's more complicated because we have more stuff in there. All those relationships in that data is still there
1:05 so if we dig in, packages are pretty straightforward but the release history, each release at least in this little model here
1:13 could have a different set of operating systems it works with, a different set of programming languages and then if you look at packages
1:20 it has that maintainer foreign key relationships so instead of having a normalization table there we just embed that within packages.
1:27 So we're going to take something kind of like this and build it in MongoDB in our application
1:33 to replace, entirely, our SQLite, SQLAlchemy based database.

Talk Python's Mastodon Michael Kennedy's Mastodon