Fork me on GitHub
#sql
<
2019-08-27
>
Ashley Smith14:08:26

How do you guys visualise your databases? I'm attempting to do some more-complex backend stuff now and I feel like I'm struggling to plan out my databases. Do you guys have like, an algorithm in your had for how you go about designing and connecting your tables?

danielneal15:08:26

I like to draw them out on a big piece of paper

danielneal15:08:30

and think about each relationship, is it one->one or one->many

danielneal15:08:04

I think I tend move from identifying entities to dependent entities

Ashley Smith15:08:10

I guess that is the best way, I was just looking up for a nice open source diagram helper but maybe pen and paper is the way forward

danielneal15:08:31

ah there’s lots of tools, but I haven’t found anything as good as pen and paper,

danielneal15:08:39

I make a lot of revisions in the early stages

danielneal15:08:51

I like that notepaper with dots

Ashley Smith15:08:06

it is indeed cute

Ashley Smith15:08:07

I'm going to try and implement a tag-experience system (imagine reddit upvotes, but there being multiple things you could be upvoted for). Trying to plan it all out 🙂

danielneal15:08:35

sounds great 🙂 like a nice thing to plan

danielneal15:08:05

drawing the database schema is my favourite bit of any project 😄

Ashley Smith16:08:27

because it allows you to truly think about what your project is going to do and it feels good getting it all planned out?

danielneal16:08:39

yeah - exactly that

Ashley Smith16:08:07

@danieleneal could I ask you to check if these tables (and comments) seem sane and readable from an outsiders perspective? I want to open source this one day so I want to make sure that my train of thought can be followed in my comments. Thinking of reordering the file? https://gist.github.com/Ashe/88157ca7561834042c59c9115f287844

danielneal08:08:00

Hey, yep the tables definitely make sense. I’m not 100% sure how some of it works regarding the points/base_value but I think that might be more clear and obvious in context of the running application. I wouldn’t worry about getting the order of the file right - databases tend to get built up over time and many migrations, so I think most devs are used to examining the schema in the database

Ashley Smith17:08:33

Thank you for your answer! And okay, the whole thing with the base_value is that if the user's points are dynamically calculated from their posts, the posts need to store the user's point values at the point of posting, thats all 🙂 Otherwise, the post would be getting the user's points constantly, which requires finding the post, which requires finding the users points etc.. Stops the cycle. But the post's true points comes from the points it starts with (base_points) AND any more generated over time etc. Its just a foothold, but thank you for your feedback 🙂