pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
REFERENCES
6+ messages / 4 participants
[nested] [flat]

* REFERENCES
@ 2002-03-08 12:28  Andre Schubert <andre.schubert@km3.de>
  0 siblings, 0 replies; 6+ messages in thread

From: Andre Schubert @ 2002-03-08 12:28 UTC (permalink / raw)
  To: pgsql-sql

Hi,

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

-- 
Andre Schubert            EMail:   Andre.Schubert@km3.de
                          Tel:     03774 6625-78
km3 teledienst GmbH       Fax:     03774 6625-79



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* REFERENCES
@ 2002-03-13 10:53  Andre Schubert <andre.schubert@km3.de>
  0 siblings, 2 replies; 6+ messages in thread

From: Andre Schubert @ 2002-03-13 10:53 UTC (permalink / raw)
  To: pgsql-sql

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

-- 
Andre Schubert            EMail:   Andre.Schubert@km3.de
                          Tel:     03774 6625-78
km3 teledienst GmbH       Fax:     03774 6625-79



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: REFERENCES
@ 2002-03-13 11:03  Laszlo Tibor <ltibor@mail.tiszanet.hu>
  parent: Andre Schubert <andre.schubert@km3.de>
  1 sibling, 1 reply; 6+ messages in thread

From: Laszlo Tibor @ 2002-03-13 11:03 UTC (permalink / raw)
  To: Andre Schubert <andre.schubert@km3.de>; pgsql-sql

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.


Regards, Tibor
ltibor@mail.tiszanet.hu




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: REFERENCES
@ 2002-03-13 12:19  Andre Schubert <andre.schubert@km3.de>
  parent: Laszlo Tibor <ltibor@mail.tiszanet.hu>
  0 siblings, 1 reply; 6+ messages in thread

From: Andre Schubert @ 2002-03-13 12:19 UTC (permalink / raw)
  To: Laszlo Tibor <ltibor@mail.tiszanet.hu>; +Cc: pgsql-sql

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.....

Thanks

> 
> Regards, Tibor
> ltibor@mail.tiszanet.hu
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: REFERENCES
@ 2002-03-13 15:57  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Andre Schubert <andre.schubert@km3.de>
  1 sibling, 0 replies; 6+ messages in thread

From: Stephan Szabo @ 2002-03-13 15:57 UTC (permalink / raw)
  To: Andre Schubert <andre.schubert@km3.de>; +Cc: pgsql-sql


On Wed, 13 Mar 2002, 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.

Correct, because you cannot currently reference a view.  Currently you
can't do that via just a references constraint, you'd need to make
triggers that do the work of the checks.

Why can't you reference a view? Well, the reason for that is that we'd
need to be able to figure out how to do the referential action checks
against the real tables referenced by the view.  Even if we put triggers
on all data changing operations on each of the tables it's not necessarily
easy to work out what row(s) of the view are being changed by the
operation.  I don't think this is likely to be changed anytime soon.




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: REFERENCES
@ 2002-03-13 17:35  Jan Wieck <janwieck@yahoo.com>
  parent: Andre Schubert <andre.schubert@km3.de>
  0 siblings, 0 replies; 6+ messages in thread

From: Jan Wieck @ 2002-03-13 17:35 UTC (permalink / raw)
  To: Andre Schubert <andre.schubert@km3.de>; +Cc: Laszlo Tibor <ltibor@mail.tiszanet.hu>; 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@Yahoo.com #



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




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2002-03-13 17:35 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-08 12:28 REFERENCES Andre Schubert <andre.schubert@km3.de>
2002-03-13 10:53 REFERENCES Andre Schubert <andre.schubert@km3.de>
2002-03-13 11:03 ` Laszlo Tibor <ltibor@mail.tiszanet.hu>
2002-03-13 12:19   ` Andre Schubert <andre.schubert@km3.de>
2002-03-13 17:35     ` Jan Wieck <janwieck@yahoo.com>
2002-03-13 15:57 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>

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