Multi-Tenant DB With Many to Many Relationships #4903
Replies: 2 comments
-
Also, it looks like just using bigserial instead of UUID's might be better? Since Citus is handling the sharding, I don't need to worry about colliding BigInts, right? |
Beta Was this translation helpful? Give feedback.
-
Sorry, we should monitor Discussions section more closely.
Assuming the table does not get a high rate of writes it should be a reference table.
Yes, it would make sense to distribute it on company_id as well to enable foreign keys to both companies and users.
Yes, bigserial works fine. |
Beta Was this translation helpful? Give feedback.
-
The Problem:
Hello! I'm new to Citus, so I'm trying to wrap my head around everything and make sure I set up my DB correctly. A slimmed down version is shown below. Basically a user can create multiple companies, and each company will have multiple stores. A user can be an "owner" of multiple companies, while also being invited to manage a company (or certain aspects of it). Each company will have one or more stores. A company can also invite a user to only manage a specific store, so they would be part of that company with access to one or more stores. Every store can have multiple employees and products and products can have multiple reviews.
I think I have the basics down, below is an sql statement for setting up a bare bones DB. Any pointers you can give, or if anything looks fishy, it would be greatly appreciated! My main concerns are:
Thanks for any potential help, I really appreciate it!
Basic diagram:
Basic SQL:
Beta Was this translation helpful? Give feedback.
All reactions