So now we're in the second half of our data modeling exploration. We've talked about one-to-many and now we're going to talk about many-to-many. Just to remember, we are in the bowels of a Django application and we're really very much talking about the model.py file and how we mess with that. We're talking a little bit about the shell and how we can look at the model.py and store stuff in the database, how we can make migrations and update the database, and then read and write data from the database through the models. So this we are narrowing in, eventually we're going to see all the rest of the Django application, the views, the forms, the templates, and we've done a little bit with routing and a little bit with admin. But just remember that we're going to look at each of these pieces in turn and eventually make some sense out of them. So in this data model which I think is a really cool data model because it shows a two one-to-many relationships and two many-to-many relationships. One very simple and one a little bit more complex, both the genre and the author are example of one-to-many. Just foreshadowing, see the one dot asterisk there on both ends of the links, well that basically says one and more up to an infinite. The other one's zero dot dot the lines covering it, zero or more and one or more. So the one-to-many has one on the one side, sometimes it has zero or one, but one on one side and then zero dot dot star or one dot dot star. So many-to-many is a different kind of creature. So remember how in the last modeling exercise, you'll notice I showed you genre and author, and then I stopped talking about them. I only talked about language and book instance. So in this one we're going to talk about genre and author, and that's because genre and author are problematic. Because really each book can have multiple authors and each book can be multiple genres, and so in that previous lecture, I kept these really simple. You see this syntax here where I'm just making a spreadsheet or another way to be thinking about it via single wide table, they're all my data in one table, but I'm starting to put commas in. So when you have commas in the user interface you just think of this as perhaps a multi-select where you have a list of things and you can highlight more than one of those things. So anytime you see this pattern, it's another form of replication, and that is that the Raspberry Pi book can be of the tech genre and the kids genre, and Wizards Stay Up Late book can be of the tech genre and the thinking genre. Some books have one genre, some books have two genres, some books have one author, some have two. But then the problem is they might have 10 authors or 20 authors. So how do we represent these things? If you're looking at either a UI or just a flat data table, you start seeing these commas, and as soon as you're seeing the commas you think to yourself, "That is an indicator that this might be a many-to-many relationship." So if this were a one-to-many not one to one. This is a one-to-many. This is a one-to-many relationship like what we did with languages. We would have a book and that would have a genre, foreign key in it that would point to a row on a genre table. That would make some sense. But that doesn't make sense because we have to have genres more than one. You could basically decide for your application developers that you can't have more than one genre. But the application developers would say, "Sorry, we're librarians and we know that there's more than one genre. So you the programmer have got to come up with a data model that represents that." So if this was a one-to-many, you could have like a genre id and each book would be able to pick a row out of the genre and so they would mark themselves. Now this is another moment where it's a warning sign and you're like, ''Well maybe we would just have two foreign keys.'' How about books only allowed to have two genres? Maybe one's not enough, but two is enough. Now let's make it three. People who are doing data modeling early in their career, they were like, "Yeah, I'll just make a genre id 01, genre id 02, and then later genre id 03, and away you go." This is completely wrong, because genres of course is a weird example, but if it's authors, there are plenty of books with, eight or nine, 10, 11 authors. So when you see yourself thinking this in your head, "Oh, I'll just add an array of things here." No. It violates the basic notion of relations and connections, and how you model stuff to the extent that you can with connections. So that leads us to what's called the many-to-many.