From: | David Johnston <polobo(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Circular references |
Date: | 2013-06-21 15:09:01 |
Message-ID: | 1371827341343-5760340.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Melvin Call wrote
> To summarize, the organization entity has an attribute of creator, which
> is a foreign key to the user table, but the user has to belong to an
> organization, which is a foreign key to the organization table. Since
> neither are nullable, there is no way to create even an initial record. My
> guess is one or both of the tables was first populated, and then the FK
> constraint(s) created.
You only need solve the chicken-egg problem once with pre-loaded data then
all new organizations can be added normally. What this requires is that
someone external to the organization be the creation user. So
"admin(at)admin_company" is the "created by" user for organization
"@client_company" and that user should also then create an
"admin(at)client_company" who would then be - generally - the creator for other
organizational objects. You just need to get "@admin_company" and
"admin(at)admin_company" into the database (via deferred constraint resolution
or before constraints are added) and you are good to go.
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/Circular-references-tp5760228p5760340.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | David Johnston | 2013-06-21 15:20:55 | Re: coalesce function |
Previous Message | Melvin Call | 2013-06-21 13:24:40 | Re: Circular references |