You have a wrong concept of foreign keys. "sta_type" is not a key of table
station_type, which cannot be referened as a foreign key.
--
From: "Rich Shepard"
Sent: Friday, July 08, 2011 1:40 AM
To:
Subject: [GENERAL]
On Thu, 7 Jul 2011, John R Pierce wrote:
if your original table has Primary Key of (sta_type, secondary_type) I
would not expect EITHER of those fields to be unique by themselves
Surely there can be more than one of the same sta_type with different
secondary_type's, just as there could be mo
-Original Message-
From: Rich Shepard [mailto:rshep...@appl-ecosys.com]
Sent: Thursday, July 07, 2011 4:05 PM
To: David Johnston
Subject: RE: [GENERAL] Add Foreign Keys To Table
On Thu, 7 Jul 2011, David Johnston wrote:
> To do what you want to do look up "CREATE INDEX
On 07/07/11 1:02 PM, Rich Shepard wrote:
On Thu, 7 Jul 2011, Alan Hodgson wrote:
create unique index index_name on table (column).
Alan,
This worked like a charm.
Many thanks for the lesson,
Rich
if your original table has Primary Key of (sta_type, secondary_type) I
would not expect
On Thu, 7 Jul 2011, John R Pierce wrote:
Since your PK of station_type is a composite, your foreign key must also be
composite.
CREATE TABLE stuffed (
id serial;
otherestuffs text;
sta varchar(50),
sec varchar(50),
FOREIGN KEY (sta, sec) REFERENCES station_type(sta_type, seconda
On Thu, 7 Jul 2011, Alan Hodgson wrote:
create unique index index_name on table (column).
Alan,
This worked like a charm.
Many thanks for the lesson,
Rich
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org
On 07/07/11 10:40 AM, Rich Shepard wrote:
I'm having difficulty finding the correct syntax to modify an existing
table. The modification is to add two columns, each a foreign
reference to
the two key columns of another table.
The other table:
CREATE TABLE station_type (
sta_type VARCHAR
-ow...@postgresql.org] On Behalf Of Rich Shepard
Sent: Thursday, July 07, 2011 3:31 PM
To: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Add Foreign Keys To Table
On Thu, 7 Jul 2011, Alan Hodgson wrote:
> It implies the composite is unique. Not sta_type.
OK. Now I understand. How, then, do
On July 7, 2011 12:30:35 PM Rich Shepard wrote:
> On Thu, 7 Jul 2011, Alan Hodgson wrote:
> > It implies the composite is unique. Not sta_type.
>
>OK. Now I understand. How, then, do I add a unique constraint to each
> component of the composite key so I can add them as foreign keys to the
> s
On Thu, 7 Jul 2011, Alan Hodgson wrote:
It implies the composite is unique. Not sta_type.
OK. Now I understand. How, then, do I add a unique constraint to each
component of the composite key so I can add them as foreign keys to the
station_information table? Or, is there another way to add t
On July 7, 2011 11:55:25 AM Rich Shepard wrote:
> On Thu, 7 Jul 2011, Alan Hodgson wrote:
> > You need a unique index on station_type.sta_type
>
> Alan,
>
>station_type(sta_type) is part of a composite primary key. Doesn't
> primary key automatically imply unique and not null?
It implies the
On Thu, 7 Jul 2011, Alan Hodgson wrote:
You need a unique index on station_type.sta_type
Alan,
station_type(sta_type) is part of a composite primary key. Doesn't primary
key automatically imply unique and not null?
Thanks,
Rich
--
Sent via pgsql-general mailing list (pgsql-general@postgr
On July 7, 2011 10:40:11 AM Rich Shepard wrote:
> alter table station_information add column sta_type varchar(50)
> unique not null references station_type(sta_type);
> NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index
> "station_information_sta_type_key" for table "station_information"
I'm having difficulty finding the correct syntax to modify an existing
table. The modification is to add two columns, each a foreign reference to
the two key columns of another table.
The other table:
CREATE TABLE station_type (
sta_type VARCHAR(50),
secondary_type VARCHAR(50),
natural
14 matches
Mail list logo