I'm currently working on an infrastructure that will allow us to have a single database for multiple applications where they all share a common set of entities (tables). Each of the schemas is mapped to a set of domain objects through an ORM.
The idea is to have one admin type application to administer common set of entities. Each of the other applications has it's own schema for it's own entities but in addition it can read only entities from the common set. Since each of those applications has it's own database login and schema ownership over it's designated schema initially this results in the common schema to grant read-only permissions to all those logins.
Perhaps to put it simple, we have the following three schemas:
- Common
- Schema_A
- Schema_B
and applications:
Admin app:
- Login Admin
- ownership of schema Common
- Domain model Common
Application A:
- Login A
- Ownership of Schema_A
- Read-only over ownership of schema Common
- Domain model Model_A
- Domain model Common
Application B:
- Login B
- Ownership of Schema_B
- Read-only over schema Common
- Domain model Model_B
- Domain model Common
The above scenario is fairly simple: add SELECT permission over schema Common to logins A and B.
But say I now want to grant Application A permission to INSERT, DELETE, UPDATE a specific table in schema Common. For clarity sake let's say we have a table called Files that any application can insert into.
The only way I managed to get this done was to grant login A all those schema permissions. If I only gave it those permissions over the table Files in the Common schema it would be denied permission in run time. Hover doing this now grants login A all the permissions over all tables in the schema - which is not really desirable.
How or where to grant the permissions needed so it only applies to a specific table?