From: | "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com> |
---|---|
To: | Daniel McBrearty <danielmcbrearty(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: table has many to many relationship with itself - how to implement? |
Date: | 2006-06-14 22:49:28 |
Message-ID: | 20060614224928.GV34196@pervasive.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Jun 14, 2006 at 10:53:36AM +0200, Daniel McBrearty wrote:
> Hi all,
>
> I have a table "phrases" that looks like this :
>
> create table phrases(
> id serial ,
> language integer references langauges(id),
> content text
> );
Might want to avoid bareword 'id' as a field name... it's a great way to
lead to confusion.
> insert into table translations ... insert what?
INSERT INTO translations VALUES(default) should work. Worst case, you
could always just select from the appropriate sequence.
> The other way to do this that I see is to lose the link table
> translations_to_phrases, and then make translations
>
> create table translations (
> id serial primary key,
> phrases integer[]
> );
>
>
> but it seems that I can no longer make postgre aware that the integers
> in translations(phrases) are references.
BTW, it's "PostgreSQL" or "Postgres" if you must.
> What is the best solution?
I'd just have a sequence for translation_id and grab from it manually
every time you create a translation, then just use that value when you
insert into translation_phrase.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461
From | Date | Subject | |
---|---|---|---|
Next Message | John DeSoi | 2006-06-15 00:10:25 | Re: tsearch2 |
Previous Message | John D. Burger | 2006-06-14 22:40:59 | Re: DEFAULT_STATISTICS_TARGET |