Subject | Re: [ib-support] Re: going beyond FOREIGN KEY ... REFERENCES |
---|---|
Author | Pete Clark |
Post date | 2003-03-09T22:35:56Z |
In message <b4gccq+41hn@...>, duilio_fos <irel_llc@...>
writes
Star_ID integer not null,
primary key (Star_ID)
)
create table Planets (
Planet_ID integer not null,
Star_ID integer not null,
primary key (Planet_ID)
)
and presumably Star_Name, Star_Type
Planet_Name, Planet_Type...
I changed your primary key, because I don't like ID's to have any
meaning other than as an ID.
Now you link your tables via the Star_ID field - each planet must be
"connected to" a star.
--
Pete Clark
NO TO WAR
No more terrorism - Arabic, American, or British
writes
>Lucas,create table Stars (
>
>>What you want to do can perfectly be done with foreign keys
>
>mmm...
>
>>you add a STAR table above your SYSTEM table, like:
>
>could you please expand on this ?
>
>I am afraid I didn't understand.
>
>We start with this database:
>
>create table Stars (
>Star_ID integer not null,
>System_ID integer,
>primary key (Star_ID)
>)
>
>create table Systems (
>System_ID integer not null,
>Planet_ID integer not null,
>primary key (System_ID,Planet_ID)
>)
>
>Are you suggesting to insert a 3th table btw Stars and Systems ?
>
>Please write the code of the new database.
>
>Thank you
>
>Duilio
Star_ID integer not null,
primary key (Star_ID)
)
create table Planets (
Planet_ID integer not null,
Star_ID integer not null,
primary key (Planet_ID)
)
and presumably Star_Name, Star_Type
Planet_Name, Planet_Type...
I changed your primary key, because I don't like ID's to have any
meaning other than as an ID.
Now you link your tables via the Star_ID field - each planet must be
"connected to" a star.
--
Pete Clark
NO TO WAR
No more terrorism - Arabic, American, or British