Skip site navigation (1) Skip section navigation (2)

Foreign keys and null

From: Oliver Fromme <olli(at)lurza(dot)secnetix(dot)de>
To: pgsql-novice(at)postgresql(dot)org
Subject: Foreign keys and null
Date: 2003-09-29 11:40:59
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice

I have a table which contains information about MRTG graphs.
Each of the graphs belongs to a device (switch, router, host)
or to a service (web server, news server etc.), so I made a
second table containing those devices and services, and used
foreign keys in the graphs table to point into the devices
table.  So far so good.  

We also have a "component table" which contains information
about hardware componets (switches, routers etc.).  So I had
the idea that I could make a link between the MRTG devices
table and the component table, i.e. put a foreign key in the
devices table pointing into the components table.

However -- The devices table also contains services which are
not in the components table (because they aren't hardware
components, but they are regarded as "virtual devices").

Normally the column should be null in those cases, but a
foreign key cannot be null, as far as I know.

Any hints or ideas?  I'm probably missing some clue here,
or maybe my tables could be organized in a better way.


Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 M√ľnchen
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

Perl is worse than Python because people wanted it worse.
        -- Larry Wall


pgsql-novice by date

Next:From: Oliver FrommeDate: 2003-09-29 12:44:03
Subject: Re: Foreign keys and null
Previous:From: Tom LaneDate: 2003-09-28 16:23:25
Subject: Re: SQL Syntax problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group