Foreign keys/unique values and views - Mailing list pgsql-general

From Einar Karttunen
Subject Foreign keys/unique values and views
Date
Msg-id Pine.LNX.4.30.0103221126250.18989-100000@melkinpaasi.cs.Helsinki.FI
Whole thread Raw
List pgsql-general
Hi

I was wondering whether there is anyway to use unique values in views.
If I create a view it drops all unique definitions. Is it possible
to reference a view with a foreign key?

for example:
>test=# CREATE TABLE ex1 (c1 int PRIMARY KEY);
>NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'ex1_pkey'
>for table 'ex1'
>CREATE
>test=# CREATE TABLE ex2 (c2 int,col char[4]);
>CREATE
>test=# CREATE VIEW v AS SELECT * FROM ex1, ex2 WHERE c1=c2;
>CREATE
>test=# \d v
>               View "v"
> Attribute |      Type      | Modifier
>-----------+----------------+----------
> c1        | integer        |
> c2        | integer        |
> col       | character(1)[] |
>View definition: SELECT ex1.c1, ex2.c2, ex2.col FROM ex1, ex2 WHERE
>(ex1.c1 = ex2.c2);
c1 is here not unique!

- Einar Karttunen








pgsql-general by date:

Previous
From: jdassen@cistron.nl (J.H.M. Dassen (Ray))
Date:
Subject: Re: Updates on Views?
Next
From: "Richard Huxton"
Date:
Subject: Re: pgsql question