[Database Design]:How to share resources among accounts? - database

Using google doc, I am able to share my documents with others. I wonder how they implement it underlying in terms of DB design?
The simplest way I imagine is to use a joining table which keeps a many-to-many relationship between resource and accounts to share.
However, I wonder if there is any well-known pattern for this? If the account has hundred resources, then hundred joining tables seem not a scale way, as for each resource you have to write specific code. Is there any thing like RBAC(role based access control) for this sharing problem?
thank you

Related

sharding(partitioning) vs multiple database

We're currently making the NFT marketplace and want to find out best architecture for serving multiple chains. I think there're two options but I don't know what's the pros and cons between them
one database with sharding per chain(ethereum, polygon and etc)
one database per chain, means multiple databases.
Requirements would be
query data across multiple chains
search/filter queries are needed to shows the items the user would be interested in.
We're using postgres, anyone have experience on this? Please shed light on this!
Thanks in advance!

How to handle a multi tenant with database per tenant application where each database has a different schema

I have a situation where I'm currently building a multitenant application where each tenant has its own database. The problem that I'm struggling with is that each database could have a vastly different structure. There are approximately 150 different tenants with each database being different. Is there a method of being able to cleanly manage this?
I'm aware of how to handle a single application with multiple databases but I'm lost on how I can implement this over several different schemas without the code base becoming unmaintainable. An initial idea would be separating the data layer so each tenant has it's own repositories and entities as an individual micro service. This isn't really scalable long term but would provide the separation of keeping the core logic separated from the individual databases but feels a bit hacky.
Are there any patterns, advice or examples where I could be pointed to so I can read further on this? Or is the method going forward just completely unfeasible?
I'm not asking anybody to write code for me or to provide a solution. I would just like a bit of advice for someone who may have worked with this kind of situation and potentially recommend steps forward.
I think creating a common data layer is your best bet. You absolutely don't have a scalable solution because you don't have a scalable problem. Hopefully they have enough in common that you can have a common mapping layer with plugins/overrides for particular entities that differ from that common core.

Database structure for multi-users web application

I'm undertaking a project with a learning purpose. Since this project is compelling to me because of its topic I want to build good foundations and maybe put it live eventual.
Since my project is quite complex, to explain you what my question is I'm gonna use a fiction project that is an agenda application.
This web application will have a calendar where the user can add events and reminders.It will be used by, lets say, 10,000 users and those 10,000 users will add thousands of events and reminders.
My question is which of the two methods would you recommend related to database structure?
Should I create a separate database with reminders and events tables for each user (on user creation) and relate the databases to a user in a separate database
or should I make one table for events, one for reminders and one for users and relate them to one another in a single database?
I haven't done any multi-user web applications so far and I am not familiar with database structures approach when it comes to many users. Please if there are any design patterns that you think of, I would appreciate sharing :)
Here's my opinion:
No, you should not create a separate database for each user. It can't scale. It means that every time you add a user, you have to create a new database? Never.
One database, multiple users - that's what relational databases are born for.
10,000 users is not that large an audience. Each creating thousands of events and reminders would mean 10M events, 10M reminders. That's not considered a large relational database.
You may need to worry about partitioning and purging old records. What kind of policy will you have in place for keeping those events and reminders? What access will users have after a year? Five years? Ten years? Those would be good topics to think about, too.
Get a good book about entity/relationship modeling and read it carefully. Anything modern on Amazon will do.
I used to work with a database where each user data was held in a separate database (your option 1) and believe me it was a nightmare to work with and the company spent enormous amount of resources to consolidate all these databases to one single database and it was not an easy task.
As #duffymo stated one database/multiple users that's what relational databases are for.

2 vBulletin forums sharing same user database?

How would I fix so that 2 vBulletin forums share the same database?
And do not tell me it is not possible, cause it is.
http://MMOwned.com
http://FPSOwned.com
If it's just a predefined set of tables that you want to share you may be able to use the FEDERATED storage engine to "share" a table across two separate databases or perhaps the MERGE storage engine to effectively share a MyISAM table across two databases.
I'm not sure what fun and games you might run into with counters, etc inside vBulletin.
Have you had a good look on the vBulletin.org forums or asked the owner of mmowned.com how they did it?

Database Design for multiple users site

I am required to work on a php project that requires the database to cater to multiple users. Generally, the idea is similar to what they have for carbonmade or basecamp, or even wordpress mu. They cater to multiple users, whom are also owners of their accounts. And if they were to cancel/terminate their account, anything on the pages/database would be removed.
I am not quite sure how should I design the database? Should it be:
separate tables for individual user account
separate databases for individual user account
or otherwise?
Kindly advise me for the best approach to this issue. Thank you very much.
How many users are we talking about?
Offhand, I like the idea of having a separate database for each user account. There are many advantages:
You can keep the schema (and your application code) simple
If a user ever wanted a copy of their database you could just dump it out and give it to them
You can easily take care of security by restricting access to each database to a given user account
You may be able to scale out more easily by adding more database servers, since you are using separate databases (there would be no common tables used by all users)
Of course, this could be a bit painful for you if you need to deploy updates to hundreds of databases, but that's what automated scripting is for.
The idea of having separate tables for each user seems like a coding nightmare. Each time you reference a shared table you will have to modify the name to match the current user's copy.

Resources