Re: REFERENCES

From: Jan Wieck <janwieck(at)yahoo(dot)com>
To: Andre Schubert <andre(dot)schubert(at)km3(dot)de>
Cc: Laszlo Tibor <ltibor(at)mail(dot)tiszanet(dot)hu>, pgsql-sql(at)postgresql(dot)org
Subject: Re: REFERENCES
Date: 2002-03-13 17:35:38
Message-ID: 200203131735.g2DHZcO31982@saturn.janwieck.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Andre Schubert wrote:
> Laszlo Tibor schrieb:
> >
> > On Wednesday, March 13, 2002 11:53 AM Behalf Of Andre Schubert wrote:
> >
> > > Hi to all,
> > >
> > > i have a simple problem and wont request assistance fro m this list.
> > > i have to tables
> > >
> > > foo:
> > > id int8 UNIQUE
> > >
> > > bar:
> > > id int8 UNIQUE
> > > foo_id int8
> > >
> > > Now i wont foo_id to be a id which exists in the foo, this could be done
> > > with foo_id REFERENCES foo (id).
> > > But what should i do if i want foo_id to be a id existing in foo or to
> > > be zero(0).
> > > I have created a view as "select id from foo UNION select 0" and tried
> > > to REFERENCE against this view, but that
> > > doesnt work.
> > > Can this problem be solved by a somebody ????
> > >
> > > Thanks
> >
> > Why do you want to use zeros? A foreign key could be NULL.
>
> Yes I know, but i need these Zeroes.....

Put a zero into foo or don't have zeroes in bar.

You might be able to work around this with custom triggers,
but that's not the real solution. It's clear that the guy
designing your data model didn't understand the difference
between zero and NULL. Fix that and your problem is solved.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-03-13 17:38:25 Re: [INIMSS] How to use OID?
Previous Message Gaetano Mendola 2002-03-13 16:58:19 Re: subquery involving 'now'