D
D
dmitryboz212019-12-10 22:26:36
PostgreSQL
dmitryboz21, 2019-12-10 22:26:36

How to implement role system in postgresql?

There is a database on postgresql (training project). There is also an application in c # that allows you to interact with this database (View / add / delete, etc.). In general, all the main functionality.
Needs to be improved. An abstract example: a database of a chain of stores. And it is necessary that the employees of each particular store see in several tables of this database only those records that belong to their store and interact only with them. And the administrator from (for example) the main office could see and edit all the records.
Please tell me how to implement this optimally, and is it possible (and if possible, how) to implement this only at the database level, without rewriting the application itself to interact with the database (well, except for minimal edits: adding authorization)
There is initial knowledge in the database. But where to dig to implement this - I'm not sure. The teacher said that he knows at least 2 methods. One is easier and the other is more difficult.
The clumsy option comes to mind first - to limit requests by adding fields with user ids to the tables that can interact with them, and allow users to perform only such requests. But I don't know how to implement it yet. And I want a simpler and better solution.
I also guess that it is possible to work somehow through the views (view) (if I correctly understood their meaning, because I had not used it before). By type, add a column to each table with the id of users who can. Receive this view and let users of the corresponding category work with the corresponding view. But I'm not sure if it's possible to edit and delete records through the view. This looks better (IMHO), but I'm not sure if there is a more elegant and beautiful solution (preferably with a minimum of body movements).
The final question: where to dig, fellow IT people?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2019-12-23
@dromenkojunior

And how did you decide?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question