This is a discussion on child fk problem within the pgsql Novice forums, part of the PostgreSQL category; --> I there, I'm trying to work with postgre, but i'm having a problem with inherits. I have a table ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I there, I'm trying to work with postgre, but i'm having a problem with inherits. I have a table (parent) that as an fk to another table. When i create a child, i loose the connection to the other table. i dont need to insert values in the parent table. what do i need to do?? tks in advance |
| |||
| On 11/30/05, Luis Silva <lfs12@hotmail.com> wrote: > > I there, I'm trying to work with postgre, but i'm having a problem with > inherits. I have a table (parent) that as an fk to another table. When i > create a child, i loose the connection to the other table. i dont need to > insert values in the parent table. what do i need to do?? tks in advance You can read the manual... of special interest to you could be the inheritance section (and read the caveats): http://www.postgresql.org/docs/8.1/s...l-inherit.html -- regards, Jaime Casanova (DBA: DataBase Aniquilator ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |
| ||||
| On Wed, 2005-11-30 at 18:45 +0000, Luis Silva wrote: > I there, I'm trying to work with postgre, but i'm having a problem > with inherits. I have a table (parent) that as an fk to another table. > When i create a child, i loose the connection to the other table. i > dont need to insert values in the parent table. what do i need to do?? > tks in advance With the current implementation of inheritance, you have to have a separate table of keys in the inheritance hierarchy: CREATE TABLE keys (id INTEGER PRIMARY KEY); CREATE TABLE parent (id INTEGER PRIMARY KEY REFERENCES keys(id), ... ); CREATE TABLE child (id INTEGER PRIMARY KEY REFERENCES keys(id), ...child columns... ) INHERITS parent; Then set up triggers to insert a key into keys if a new key is inserted in any table in the hierarchy and to delete from keys when a record is deleted from the hierarchy. Then any other table that needs to reference the hierarchy should reference keys instead. Oliver Elphick ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |