S
S
Sergey2017-02-19 17:52:40
SQL
Sergey, 2017-02-19 17:52:40

Is it worth it to spread the data in the database: the user has his own schema?

At the moment, in our project, user data is stored in a single database, in a single scheme, i.e. it looks something like this:
5085eb2e7cd842b2b85eeda9eb80f079.png
Now I'm thinking about separating data like this:
a027c90384ae4a4d850acb8abb31c66a.png
This is necessary so that we can restore the data of a particular user without touching the rest if something happens.
I am concerned about the following questions:
1. Is it difficult to work with such a database structure?
2. Whether it is easy to carry out migrations of structure of the data on all schemes further
3. Perhaps to me it is better to create separate base on the user?
4. Can you suggest something?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
igruschkafox, 2017-02-23
@korenb_white

1. Is it difficult to work with such a database structure? - Yes, it will
be hemorrhoids, especially in terms of littering the database with different tables ,
but it is easier to operate (each user sees only his own data and works with them himself) this decision can add problems at the given operation 3. Can to me it is better to create separate base on the user? - in no case, to produce databases on the server - which will not be known how they will be exploited - A very bad option (and if a person quits - then what to do with this database) 4. Maybe you can suggest something? - I like the option suggested by Sumor
Actually, this is how Microsoft recommends doing it.

M
mletov, 2017-02-19
@mletov

You under kazhy user are going to get 3 tables? A very strange choice.
To restore data, it is easier to write a storage that deletes the current data for this user in these tables and inserts from the desired backup

S
Sumor, 2017-02-19
@Sumor

Works - do not touch.
But in fact, the question is what does not suit you in the current storage and how related are the data of different users.
If user data is closely intertwined, that is, Products, Items are associated with several users at the same time, but it may not make sense to bother like that.
If, on the contrary, user data is separated, then you can consider creating your own database for each user. When a user is created, it will be created, when deleted, it will be deleted, saving / restoring / rights - everything will be.
If you want to play around with schemas, it's better to use not tables, but views. For each user, create views in your schema with the selection of only his records and setting rights.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question