Subject Re: [firebird-support] Sample Constraint between Parent-Child tables
Author Helen Borrie
At 06:56 PM 12/10/2004 +0530, you wrote:

>Hi all
>Can anybody provide me a sample (pref. to be done in Marathon) to create
>delete cascade constraint between Parent-Child tables. I have tried but
>was not successful and have not been able to fathom the error messages
>enough to solve them.

create table master (
id integer not null,
data varchar(10),
constraint pk_master
primary key(id);


create table detail (
id integer not null,
data varchar(20),
master_id integer,
constraint pk_detail
primary key (id),
constraint fk_detail_master
foreign key (master_id)
references master(id)
on delete cascade);


Note, there are other ways to add constraints, too. Most people create the
"bare" tables first, commit them, then add the constraints using ALTER TABLE.

As for "to be done in Marathon" - hmm, you don't really seem to understand
how SQL works.

The above example is four statements. An SQL engine runs one statement at
a time. so....
--- You can put all of them into a script and execute that (script executor
--- you can break them up into four individual statements and run each one,
in the correct order, from the interactive command tool.

Have you considered equipping yourself with the IB6 Language Reference and
perhaps googling for some other SQL documentation? It's going to be
between "difficult" and "impossible" for you to work with an SQL database
system if you don't know SQL.