Thread: Conditioned access to a database

Conditioned access to a database

From
Paulo da Silva
Date:
Hello,

I'm evaluating sql/postgresql for the following purpose:
I need to have a database with lots of "records".
I need to allow groups of users to access sets of
those records grouped by the contents of one field.
For example, the group A can only access records that
have the dptm field = "A". Is this possible?

If the subject is not simple, pls just tell me
which doc to read.

TIA

Paulo

--
"Esta Ilha pequena que habitamos"
                Luis de Camoes
(International version soon available)
Paulo (pdasilva@esoterica.pt)

Re: [GENERAL] Conditioned access to a database

From
tolik@icomm.ru (Anatoly K. Lasareff)
Date:
>>>>> "PdS" == Paulo da Silva <pdasilva@esoterica.pt> writes:

 PdS> Hello,
 PdS> I'm evaluating sql/postgresql for the following purpose:
 PdS> I need to have a database with lots of "records".
 PdS> I need to allow groups of users to access sets of
 PdS> those records grouped by the contents of one field.
 PdS> For example, the group A can only access records that
 PdS> have the dptm field = "A". Is this possible?

 PdS> If the subject is not simple, pls just tell me
 PdS> which doc to read.

Suppose you have table:

create table a (
  tag int,
  info text
);

and you want controll user's depend on the 'tag' field value. I think
you can do following:

create view v1 as select info from a where tag = 1;
create view v2 as select info from a where tag = 2;
create view v3 as select info from a where tag = 3;

revoke all on a from public;

grant select on v1 to user1, user2...;
grant select on v2 to group gr1, ...;
. . .


--
Anatoly K. Lasareff              Email:       tolik@icomm.ru
Senior programmer