Обсуждение: Foreign key problem in Postgresql-7.2

Поиск
Список
Период
Сортировка

Foreign key problem in Postgresql-7.2

От
Thirumoorthy Bhuvneswari
Дата:
hi,
I am using Postgresql-7.1.3 with Redhat Linux-7.1 for
my application developed in Java. I have created some
tables with foreign keys which are not the primary
keys in the master tables. Its working fine in
Linux-7.1.3. I tried to upgrade my system with
Postgresql-7.2 and did restore of my database. It did
not accept such foreign keys. Though the design may
not be of its best normalization form, I use such
foreign keys for ease of maintenance. How can I get
them in Postgresql-7.2. Thanks in advance.

bhuvana.

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

Re: Foreign key problem in Postgresql-7.2

От
Stephan Szabo
Дата:
On Mon, 20 May 2002, Thirumoorthy Bhuvneswari wrote:

> hi,
> I am using Postgresql-7.1.3 with Redhat Linux-7.1 for
> my application developed in Java. I have created some
> tables with foreign keys which are not the primary
> keys in the master tables. Its working fine in
> Linux-7.1.3. I tried to upgrade my system with
> Postgresql-7.2 and did restore of my database. It did
> not accept such foreign keys. Though the design may
> not be of its best normalization form, I use such
> foreign keys for ease of maintenance. How can I get
> them in Postgresql-7.2. Thanks in advance.

Well, the values do not necessarily need to be primary keys,
but they must be unique.  Even in 7.1.x, there was no
check done to guarantee that the values are unique,
but for non-unique referenced columns the results
would sometimes end up being incorrect.



Re: Foreign key problem in Postgresql-7.2

От
"Wm. G. Urquhart"
Дата:
On Mon, 20 May 2002, Thirumoorthy Bhuvneswari wrote:

> hi,
> I am using Postgresql-7.1.3 with Redhat Linux-7.1 for
> my application developed in Java. I have created some
> tables with foreign keys which are not the primary
> keys in the master tables. Its working fine in
> Linux-7.1.3. I tried to upgrade my system with
> Postgresql-7.2 and did restore of my database. It did
> not accept such foreign keys. Though the design may
> not be of its best normalization form, I use such
> foreign keys for ease of maintenance. How can I get
> them in Postgresql-7.2. Thanks in advance.
>
> bhuvana.

Hi,

ALTER TABLE table_name ADD CONSTRAINT const_name FOREIGN KEY (Column_Name)
REFERENCES ref_table_name(ref_column_name) ;

Should do the trick.

--
Regards,


Wm. G. Urquhart
Custom Software Solutions
http://www.wurquhart.co.uk