pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: ogjunk-pgjedan@yahoo.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Referential integrity broken (8.0.3), sub-select help
Date: Tue, 21 Mar 2006 07:08:38 -0800 (PST)
Message-ID: <20060321070446.C70702@megazone.bigpanda.com> (raw)
In-Reply-To: <20060321145839.68211.qmail@web50301.mail.yahoo.com>
References: <20060321145839.68211.qmail@web50301.mail.yahoo.com>

On Tue, 21 Mar 2006 ogjunk-pgjedan@yahoo.com wrote:

> I've got 2 tables, "url" (U), and "bookmark" (B), with "bookmark" pointing to "url" via FK.

That's not what your schema below has.  Your fragment below has URL
pointing to bookmark.

> Somehow I ended up with some rows in B referencing non-existent rows in U.

With the below, this is entirely possible, since you're only guaranteeing
that URLs have valid bookmarks not the other way around.  Are you sure the
below is actually what you have?

> This sounds super strange and dangerous to me, and it's not clear to me how/why PG let this happen.
> I'm using 8.0.3.
>
> Here are the table references I just mentioned:
>
> Table "bookmark":
>      id                  SERIAL
>                          CONSTRAINT pk_bookmark_id PRIMARY KEY
>
>  Table "url":
>     url_id              INTEGER
>                          CONSTRAINT fk_bookmark_id REFERENCES bookmark(id)




view thread (7+ messages)  latest in thread

Message-ID: <20060321070446.C70702@megazone.bigpanda.com>
Permalink:  ../20060321070446.C70702@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20060321070446.C70702@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, ogjunk-pgjedan@yahoo.com
  Subject: Re: Referential integrity broken (8.0.3), sub-select help
  In-Reply-To: <20060321070446.C70702@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox