Again about foreign keys and inheritance

From: Dedov Anton <bada(at)paragon(dot)krasnoyarsk(dot)su>
To: pgsql-sql(at)postgresql(dot)org
Subject: Again about foreign keys and inheritance
Date: 2002-01-29 03:45:02
Message-ID: 20020129104502.0f2799c6.bada@paragon.krasnoyarsk.su
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all.

Does the problem of accessing an whole inheritance's tree via foreign key resolved?

The problem is:
in next example an insert into table roaming will fail. Can I solve it anyway?
Without foreign keys on parent tables IMHO inheritance is meaningless...

Dedov Anton

EXAMPLE:

create table devs (
devid int,
owner int,
devtype varchar,

primary key (devid) --,
-- foreign key (owner) references ab,
-- foreign key (devtype) references devtypes
);

create table roaming (
dev int,
node int,
validto timestamp,

primary key (dev, node),
foreign key (dev) references devs --,
-- foreign key (node) references nodes
);

create table devs_pocsag (
capcod int unique not null check (capcod > 0),
subcod int not null check (subcod >= 0),
speed int not null,
freq float4 not null,
ptype varchar not null,
is_inv boolean default 'f',

primary key (devid) --,
-- foreign key (speed) references pocsag_speeds,
-- foreign key (ptype) references pocsag_ptypes,
-- foreign key (freq) references pocsag_freqs
) inherits (devs);

--...

select * from devs_pocsag;
devid | owner | devtype | capcod | subcod | speed | freq | ptype | is_inv
-------+--------+---------+--------+--------+-------+-------+------------+--------
0 | 240008 | POCSAG | 240008 | 0 | 1200 | 159.2 | Millennium | f

insert into roaming (dev,node) values (0,95);
ERROR: <unnamed> referential integrity violation - key referenced from roaming not found in devs

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Johny Jugianto 2002-01-29 11:02:34 get array data with range
Previous Message Andre Holzner 2002-01-28 23:52:21 plpgsql function with more than one array argument