Foreign keys and null - Mailing list pgsql-novice

From Oliver Fromme
Subject Foreign keys and null
Date
Msg-id 200309291140.h8TBexmt025048@lurza.secnetix.de
Whole thread Raw
Responses Re: Foreign keys and null
List pgsql-novice
Hi,

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.

Regards
   Oliver

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

Previous
From: Tom Lane
Date:
Subject: Re: SQL Syntax problem
Next
From: Oliver Fromme
Date:
Subject: Re: Foreign keys and null