pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PFC <lists@boutiquenumerique.com>
To: lucas@presserv.org
To: pgsql-sql@postgresql.org
Subject: Re: Relation in tables
Date: Wed, 16 Feb 2005 19:56:25 +0100
Message-ID: <opsmaz8b14th1vuj@musicbox> (raw)
In-Reply-To: <20050216134301.5myrfpr3ck6bmswc@www.presserv.org>
References: <20050216134301.5myrfpr3ck6bmswc@www.presserv.org>


> 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.



view thread (4+ messages)  latest in thread

Message-ID: <opsmaz8b14th1vuj@musicbox>
Permalink:  ../opsmaz8b14th1vuj@musicbox/
Also on:    postgresql.org/message-id/opsmaz8b14th1vuj@musicbox

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lists@boutiquenumerique.com, lucas@presserv.org
  Subject: Re: Relation in tables
  In-Reply-To: <opsmaz8b14th1vuj@musicbox>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox