Prisma TRPC Postgres Question - Should I have 1 large Model or smaller tables and query them all?

I don't find an obvious 'best practice' for how to layout a database design for 20-50 column databases, should you limit the column size and query more tables or have larger tables to have a single query point?
11 Replies
needmorewood
needmorewood•3y ago
It super depends on your data.... Maybe try and find some generic resources of database modelling? Not sure how anyone can give a best practice without some more info
Neto
Neto•3y ago
if you need the 20-50 columns every time you have to accept the pain if you have a pattern of accessing data probably spliting into smaller tables + 1-1 relationship
Neto
Neto•3y ago
something like
needmorewood
needmorewood•3y ago
can you group things by tables? ie users, books, products, etc anything? thinking of it as columns seems odd
Neto
Neto•3y ago
if most of the time you accept some slice of the row can make sense to split into smaller tables you add business logic instead of bandwidth] logic 50 columns, on a massive vertical table a lot of bandwidth
Debaucus
DebaucusOP•3y ago
That's more or less what I am asking. For a blog example, I am doing title, short description, content, discord, twitter, facebook, userIcon, userWebsite etc etc.. Does it make sense to break them down or query everything every time? I understand its not the best question, its coming from someone already lacking a bit of knowledge to word it better 😅
needmorewood
needmorewood•3y ago
So for a blog that would be one column with all of the properties of the blog If you had something like blog comments that would be a seperate table containing everything a comment would have had would be tied to a blog record these are logical seperations of entities
Debaucus
DebaucusOP•3y ago
Table not column?
needmorewood
needmorewood•3y ago
you wouldnt put a blog in a user record because that wouldnt make sense yea so a blogs table each record would be a blog
Debaucus
DebaucusOP•3y ago
Got ya
needmorewood
needmorewood•3y ago
a blog record contains title, body, user_id etc if you want to find a users blogs and know their id you can query a collection of their blogs etc
Want results from more Discord servers?
Add your server