Unix Technical Forum

BUG #1688: inheritance and foreign key creation problem

This is a discussion on BUG #1688: inheritance and foreign key creation problem within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 1688 Logged by: Email address: wrobell@pld-linux.org PostgreSQL version: 8.0.3 Operating ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 09:53 AM
 
Posts: n/a
Default BUG #1688: inheritance and foreign key creation problem


The following bug has been logged online:

Bug reference: 1688
Logged by:
Email address: wrobell@pld-linux.org
PostgreSQL version: 8.0.3
Operating system: Linux
Description: inheritance and foreign key creation problem
Details:

-----------
create table employee (
__key__ integer,
name varchar(10) not null,
surname varchar(20) not null,
phone varchar(12) not null,
unique (name, surname),
primary key (__key__)
);

create table boss (
dep_fkey integer unique
) inherits(employee);


create table department (
__key__ integer,
boss_fkey integer unique,
primary key (__key__),
foreign key (boss_fkey) references boss(__key__) initially deferred
);

-----------

We can see that boss relation has __key__ column (inherited from employee
relation), but when executing above script PostgreSQL fails with message:

psql:script.sql:20: ERROR: there is no unique constraint matching given
keys for referenced table "boss"

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 09:53 AM
Stephan Szabo
 
Posts: n/a
Default Re: BUG #1688: inheritance and foreign key creation problem

On Sun, 29 May 2005, wrote:

>
> The following bug has been logged online:
>
> Bug reference: 1688
> Logged by:
> Email address: wrobell@pld-linux.org
> PostgreSQL version: 8.0.3
> Operating system: Linux
> Description: inheritance and foreign key creation problem
> Details:
>
> -----------
> create table employee (
> __key__ integer,
> name varchar(10) not null,
> surname varchar(20) not null,
> phone varchar(12) not null,
> unique (name, surname),
> primary key (__key__)
> );
>
> create table boss (
> dep_fkey integer unique
> ) inherits(employee);
>
>
> create table department (
> __key__ integer,
> boss_fkey integer unique,
> primary key (__key__),
> foreign key (boss_fkey) references boss(__key__) initially deferred
> );


Unique constraints do not currently inherit, so right now, there is no
unique constraint on boss.__key__ and you'll be able to insert duplicates.
Right now, you can almost work around this by explicitly placing a unique
constraint on the column, however, that only guarantees uniqueness within
a table not between employee and boss.


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:18 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com