Search Postgresql Archives

Create Foreign Key Constraint on a View

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm attempting to create a Foreign Key Constraint between a table and a 
view in PostgreSQL 8.3. Ex:

ALTER TABLE public.table ADD CONSTRAINT table_to_view_fk
FOREIGN KEY (view_key)
REFERENCES public.view (view_key)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE; 

However, I get an error about public.view not being a table.  I know in 
other RDBMS (Oracle) I can specify a constraint on a view, with limited 
functionality.  

The problem I'm specifically trying to solve is a typical Data 
Warehousing problem where I have a "Fact" that requires two instances of 
a Foreign Key join on a Time Dimension.  So, the solution that was 
suggested to me is to make two views of the Time Dimension that will then 
be joined to the Fact table (giving  unique fact specfic names in the 
view definition for the constraints)  I know I could just make a copy of 
the time dimension, but it seems like a more elegant solution must be 
available.


-- 
--Christopher Brodt

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux