From: | Gregory Seidman <gss+pg(at)cs(dot)brown(dot)edu> |
---|---|
To: | postgres list <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: circular REFERENCES |
Date: | 2002-06-18 22:28:14 |
Message-ID: | 20020618222814.GA21495@cs.brown.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Stephan Szabo sez:
} On Tue, 18 Jun 2002, Gregory Seidman wrote:
}
} > I would like to define two tables:
} >
} > CREATE TABLE Person (
} > id SERIAL not null,
} > -- ...
} > team_membership integer default null REFERENCES Team(id),
} > primary key (id)
} > );
} > CREATE TABLE Person (
} > id SERIAL not null,
} > -- ...
} > captain integer not null REFERENCES Person(id),
} > primary key (uid)
} > );
} >
} > Of course, I can't define them that way. Is there any better way to take
} > care of this than to leave out the REFERENCES in the first table and add it
} > with ALTER TABLE ADD CONTRAINT after the second table has been defined?
}
} I assume you meant Team on the second create table. Pretty much you will
} need to use alter table to add one of them. In addition, are you sure
} you want those to be immediately checked? Generally when you have a
} recursive structure like that one or both of the constraints is deferred.
Yep, the second table was supposed to be Team. And I do want them both to
be immediately checked. Users will be added with a NULL team, and will be
able to join a team.
--Greg
From | Date | Subject | |
---|---|---|---|
Next Message | Varun Kacholia | 2002-06-18 22:42:06 | Re: Highly obscure and erratic |
Previous Message | Stephan Szabo | 2002-06-18 22:13:19 | Re: circular REFERENCES |