Foreign keys and null

Поиск
Список
Период
Сортировка
От Oliver Fromme
Тема Foreign keys and null
Дата
Msg-id 200309291140.h8TBexmt025048@lurza.secnetix.de
обсуждение исходный текст
Ответы Re: Foreign keys and null  (Oliver Fromme <olli@lurza.secnetix.de>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: SQL Syntax problem
Следующее
От: Oliver Fromme
Дата:
Сообщение: Re: Foreign keys and null