Re: Relation in tables

From: PFC <lists(at)boutiquenumerique(dot)com>
To: lucas(at)presserv(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: Relation in tables
Date: 2005-02-16 18:56:25
Message-ID: opsmaz8b14th1vuj@musicbox
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


> Hello all...
> I am starting in Postgresql...
> And I have a question:
> I am developing a DB system to manage products, but the products may be
> separated by departaments (with its respectives coluns)... Like:
>
> CREATE TABLE products(
> id serial primary key,
> desc valchar(100),
> ...
> );
>
> Okay, but the products is typed by "amount departament" and this
> departament
> should not have access to other coluns like "values, Money, etc...".
> The "finances departament" may modify the data into products table, but
> this
> departament should not have access to coluns like "amounts, etc...".
>
> I' ve tried to create the products table with INHERITS but its not
> right...
> look:

Use a view per department, which show/hide the columns according to your
liking. Give each department a schema and put everything related to it
inside for cleanliness. Use UPDATE triggers on the views, which in fact
write to the products table, so that the departments can only update the
columns you like. You can even make some columns readable but not
writeable, by raising an exception if a modification is attempted on that
column.

If you want to reuse your code between departments, you will want all the
views to have the same columns, so make them return NULL for the fields
that they cannot see.

Finally don't forget to make the products table inaccessible the
departments.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2005-02-16 19:58:22 Re: Count Columns
Previous Message PFC 2005-02-16 18:52:13 Re: More efficient OR