Again about foreign keys and inheritance
Again about foreign keys and inheritance
От:
Dedov Anton <bada@paragon.krasnoyarsk.su>
Дата:
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: referential integrity violation - key referenced from roaming not found in devs
Re: Again about foreign keys and inheritance
От:
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Дата:
On Tue, 29 Jan 2002, Dedov Anton wrote: > Does the problem of accessing an whole inheritance's tree via foreign > key resolved? Not yet. I wouldn't promise anything for 7.3 either (I am looking at it as part of RI changes, but I'm more concerned with getting it properly happy for all the non-inheritance cases).