Subject Re: going beyond FOREIGN KEY ... REFERENCES
Author duilio_fos
Martijn,

> Your metadata is wrong

I can only hope it isn't: I spent the whole afternoon setting up the
code :)

>what is a "system"?

well, I know that

1. the Sun is a star
2. the Sun and the planets we are familiar with (Mercury, Venus,
Earth, Mars etc) make the "solar system"
3. accordingly, I called a "system" what is made by a star and all
the planets around it

>If it cannot be uniquely identified by a "systemID" alone?

_it is_ identified by the System_ID alone.

>It always has a PlanetID??

Table SYSTEMS stores the planets related to the star X.

If the star_ID of the SUN is 1, you would read in SYSTEMS:

STAR_ID PLANET_ID
1 1000
1 1001
1 1002
... ...

In a different table (not reported here for clarity) you would read

PLANET_ID DESCRIPTION
1000 Mercury
1001 Venus
1002 Earth
... ...

Please try to see the abstract problem only:

there is a Table (Master) (that you can image made of several fields
and complex enough in its structure) where a field F1 points to
another table (Slave).

You don't want dangling links in Master Table.

Usually you would write

ALTER TABLE Master ADD FOREIGN KEY (F1) REFERENCES
Slave (F1) on update cascade on delete cascade

However, you cannot do it, because values of field F1 are not unique
in Slave.

I hope that I explained the problem better.

Thank you

Duilio