Foreign keys/unique values and views

From: Einar Karttunen <ekarttun(at)cs(dot)Helsinki(dot)FI>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Foreign keys/unique values and views
Date: 2001-03-22 09:41:55
Message-ID: Pine.LNX.4.30.0103221126250.18989-100000@melkinpaasi.cs.Helsinki.FI
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marko Kreen 2001-03-22 10:02:09 Re: Call for platforms
Previous Message Richard Huxton 2001-03-22 09:28:38 Re: pgsql question