Unix Technical Forum

child fk problem

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 ...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 10:20 PM
Luis Silva
 
Posts: n/a
Default child fk problem

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 10:20 PM
Jaime Casanova
 
Posts: n/a
Default Re: child fk problem

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 10:20 PM
Oliver Elphick
 
Posts: n/a
Default Re: child fk problem

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

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

« Error | Re: Error »

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 03:50 PM.


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