How do you structure your schemas?
Hi,
how do you structure your schemas? I'm building a larger app, and the schemas are growing, so it doesn't make sense to have all tables in one schema.
However, creating multiple schemas as multiple files (screenshot included) is also something that I'm not in favor of.
Thanks
9 Replies
I've thought about grouping similar tables such as companies and halls or hall separators to one file that exports these three tables
I have a "db" folder, inside that I have things grouped by domain inside of a single file
What do you mean grouped by domain?
Sorry, relational databases are not my strong point
Just logical groupings, and then core business related things are in index.ts
so I have users.ts with auth stuff, preferences, etc.
Oh get it
index.ts with categories, transactions, accounts, invoices, etc.
Makes sense
don't know if it makes sense for most, but for me it kinda does, especially when importing
import user from '~/db/user.ts"
import {account, invoice} from '~/db'
might make more sense to just make index a barrel, but I haven't put too much thought into it
Thanks for the input
I can now choose approach in peace as I have at least a opinion from someone else 😄
Also, suppose I have a many to many relation between
users
and projects
. I need to create a JOIN table, in which file should I create the JOIN table and relations. Under users.ts
or projects.ts
?
Or should I have a separate file for JOIN tables?