Subject foreign key error
Author duilio_fos
I am writing a program to optimize bus drivers schedules.

I have a LOCATIONS table

create table locations (
id_loc d_progr not null,
cod_loc d_code_long not null,
des_loc d_description_long not null,
depot d_bool not null,
primary key (id_loc)
) !!

please note that bus depots have 1 in field DEPOT (otherwise the
field value is 0).

Also, I have a DUTIES table

create table duties (
id_dty d_progr not null,
fm_time d_time_qty not null,
to_time d_time_qty not null,
fm_depot d_progr not null,
to_depot d_progr not null,
primary key (id_dty)
) !!

I wrote

alter table duties add foreign key (fm_depot,1) references locations
(id_loc,depot) !!

I thought it would be a very clever solution to the problem of
checking that

1. fm_depot is in the locations table
2. fm_depot is a depot all right

However, the compiler complains with a "Token unknown" message when
it meets the "1" in the statement, so maybe this solution isn't as
clever as I thought...

So a before-insert/ before-update trigger is the only way to check
the condition ?

Thank you

Duilio Foschi