Re: Circular references - Mailing list pgsql-general

From David Johnston
Subject Re: Circular references
Date
Msg-id 1371827341343-5760340.post@n5.nabble.com
Whole thread Raw
In response to Re: Circular references  (Melvin Call <melvincall979@gmail.com>)
List 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@admin_company" is the "created by" user for organization
"@client_company" and that user should also then create an
"admin@client_company" who would then be - generally - the creator for other
organizational objects.  You just need to get "@admin_company" and
"admin@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.


pgsql-general by date:

Previous
From: Melvin Call
Date:
Subject: Re: Circular references
Next
From: David Johnston
Date:
Subject: Re: coalesce function