Effective PyCharm Transcripts
Lecture: Database diagrams
Login or purchase this course to watch this video and the rest of the course contents.
0:00 If we want to understand the relationship between all the tables, we can look at our SQLAlchemy classes over here.
0:07 And yeah, you can see there is a relationship from releases, to packages. That's a pretty limited view.
0:13 You kinda gotta go through all these files and the more complicated that your database gets the harder it is to keep that all in your mind.
0:19 Wouldn't it be cool if we had a picture? Well, let's make one So PyCharm is actually really good at creating pictures and
0:26 graphs that show us how this works. So go over here to our tables and we right click,
0:31 we go to this diagram and we can either see a visualization or a visualization pop up. The only difference one is like a separate window.
0:39 The other one is a tab. So let's just look at this visualization here check that out. You can see all the tables,
0:44 all their relationships. Again, you can even see where the indexes are, where the relationships are, where the foreign keys are.
0:52 All the good stuff that you might want. Now, the layout might not be exactly what you're hoping for.
0:57 For example, I don't really want SQLite Master ever. This is like something that SQLite uses to maintain itself.
1:03 We can just highlight that and hit delete also let's put these sort of separate stand alone tables over here like this. And yeah, this looks all right.
1:15 We can kind of move that over over like this or so and then we can say a round edges and it'll actually fix things up a little bit that allow us
1:24 to put this here. Maybe do one more time, nope, didn't like that. Let's put this back. There we go. We've got things organized the way we like,
1:35 we can say fit content, so it's a little bit bigger. Close it and if we come back and ask for the diagram again,
1:42 remember how I put it so you can organize these things just like you like. So it's easy to understand and yeah, that's a really, really good.
1:50 The next thing that we can do That you might want to focus on on a real complex database is if you had 50 or 100 tables,
1:59 you don't want them all just piled on here. Maybe you're focused specifically on a certain use case. And for that we can come over and say,
2:07 let's say we're focused on packages, releases and maintainers. You just highlight those right click generated diagram and now we have
2:19 a new visualization that just has those pieces. Let's put this in the middle, put this on the side, it wants to put it like that,
2:30 doesn't it? There we go. I got to organize but see how we can just focus on a little part of our application. And somehow we got users in here,
2:39 I don't really even need users so we can just have a nice clean model here
2:46 that shows us the relationship between packages releases and maintainers If you want to focus in on a subset of your database, this is, like I said,
2:55 especially useful when you've got a ton of tables in real world applications that have been around for a long time, 50, 100 tables entirely possible.
3:04 Right? So you don't want to try to understand it all at once. Take little pieces, little use cases and so on. So if you're working with databases,
3:11 be sure to use the diagrams to visualize them and understand them better.