Re: [GENERAL] Foreign key constraint question

2007-07-22 Thread Perry Smith
On Jul 22, 2007, at 10:35 AM, Alvaro Herrera wrote: Nis Jørgensen wrote: Alvaro Herrera skrev: Nis Jørgensen wrote: What if, for instance, I want to render a list of shapes? To render the shape, I need to get its data, to get its data, I need to know what type it is. ISTM that the easiest w

Re: [GENERAL] Foreign key constraint question

2007-07-22 Thread Alvaro Herrera
Nis Jørgensen wrote: > Alvaro Herrera skrev: > > Nis Jørgensen wrote: > > > >> What if, for instance, I want to render a list of shapes? > >> > >> To render the shape, I need to get its data, to get its data, I > >> need to know what type it is. ISTM that the easiest way to achieve > >> this is s

Re: [GENERAL] Foreign key constraint question

2007-07-22 Thread Sergey Konoplev
Well, what about using inheritence and relation identifiers? ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org/

Re: [GENERAL] Foreign key constraint question

2007-07-22 Thread Nis Jørgensen
Alvaro Herrera skrev: > Nis Jørgensen wrote: > >> What if, for instance, I want to render a list of shapes? >> >> To render the shape, I need to get its data, to get its data, I >> need to know what type it is. ISTM that the easiest way to achieve >> this is storing the type info at the "top" of

Re: [GENERAL] Foreign key constraint question

2007-07-21 Thread Alvaro Herrera
Nis Jørgensen wrote: > What if, for instance, I want to render a list of shapes? > > To render the shape, I need to get its data, to get its data, I need to > know what type it is. ISTM that the easiest way to achieve this is > storing the type info at the "top" of the table hierarchy. Try addin

Re: [GENERAL] Foreign key constraint question

2007-07-21 Thread Lew
Perry Smith wrote: I want to do something like this: ALTER TABLE companies ADD CONSTRAINT fk_companies_item_id FOREIGN KEY (item_id, 'Company') REFERENCES item_bases(item_id, item_type) INITIALLY DEFERRED I could add a column to companies that is always se

Re: [GENERAL] Foreign key constraint question

2007-07-21 Thread Nis Jørgensen
Jeff Davis skrev: > On Fri, 2007-07-20 at 19:18 -0500, Perry Smith wrote: >>> The relational model handles inheritance and polymorphism very well if >>> you don't store types as values. >> What if I have just an id for an item? This will happen when another >> table references an item. How do I

Re: [GENERAL] Foreign key constraint question

2007-07-20 Thread Michael Glaesemann
On Jul 20, 2007, at 19:37 , Jeff Davis wrote: I only mentioned it because in 8.3 it will be useful for general use. I don't know what's changing about it between now and then, but it's becoming "un-deprecated". AFAIK, nothing's changed in the actual constraint trigger code: it's just a do

Re: [GENERAL] Foreign key constraint question

2007-07-20 Thread Jeff Davis
On Fri, 2007-07-20 at 19:18 -0500, Perry Smith wrote: > > The relational model handles inheritance and polymorphism very well if > > you don't store types as values. > > What if I have just an id for an item? This will happen when another > table references an item. How do I know what type it

Re: [GENERAL] Foreign key constraint question

2007-07-20 Thread Perry Smith
On Jul 20, 2007, at 7:01 PM, Jeff Davis wrote: On Fri, 2007-07-20 at 09:27 -0500, Perry Smith wrote: On Jul 20, 2007, at 9:06 AM, Michael Fuhr wrote: On Fri, Jul 20, 2007 at 08:57:25AM -0500, Perry Smith wrote: I want to do something like this: ALTER TABLE companies ADD CONSTRAINT fk_compa

Re: [GENERAL] Foreign key constraint question

2007-07-20 Thread Jeff Davis
On Fri, 2007-07-20 at 09:27 -0500, Perry Smith wrote: > On Jul 20, 2007, at 9:06 AM, Michael Fuhr wrote: > > > On Fri, Jul 20, 2007 at 08:57:25AM -0500, Perry Smith wrote: > >> I want to do something like this: > >> > >> ALTER TABLE companies ADD CONSTRAINT fk_companies_item_id > >> F

Re: [GENERAL] Foreign key constraint question

2007-07-20 Thread Perry Smith
On Jul 20, 2007, at 9:06 AM, Michael Fuhr wrote: On Fri, Jul 20, 2007 at 08:57:25AM -0500, Perry Smith wrote: I want to do something like this: ALTER TABLE companies ADD CONSTRAINT fk_companies_item_id FOREIGN KEY (item_id, 'Company') REFERENCES item_bases(item_id, it

Re: [GENERAL] Foreign key constraint question

2007-07-20 Thread Michael Fuhr
On Fri, Jul 20, 2007 at 08:57:25AM -0500, Perry Smith wrote: > I want to do something like this: > > ALTER TABLE companies ADD CONSTRAINT fk_companies_item_id > FOREIGN KEY (item_id, 'Company') > REFERENCES item_bases(item_id, item_type) > INITIALLY DEFERRED

[GENERAL] Foreign key constraint question

2007-07-20 Thread Perry Smith
I want to do something like this: ALTER TABLE companies ADD CONSTRAINT fk_companies_item_id FOREIGN KEY (item_id, 'Company') REFERENCES item_bases(item_id, item_type) INITIALLY DEFERRED I could add a column to companies that is always set to "Company" but