Re: Relation in tables - Mailing list pgsql-sql

From PFC
Subject Re: Relation in tables
Date
Msg-id opsmaz8b14th1vuj@musicbox
Whole thread Raw
In response to Relation in tables  (lucas@presserv.org)
Responses UPDATE TRIGGER on view WAS: Re: Relation in tables  ("Keith Worthington" <keithw@narrowpathinc.com>)
Re: Relation in tables  (lucas@presserv.org)
List 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.


pgsql-sql by date:

Previous
From: PFC
Date:
Subject: Re: More efficient OR
Next
From: "Ray Madigan"
Date:
Subject: Count Columns