"MaFai" <[EMAIL PROTECTED]> wrote:
> 
> After I create this table,and add foreign key tno to this table.
> If I delete "tno" in "p_program_type" table,it would alarm that some data still in 
> "p_schedule".
> How can I define the "p_schedule" or "p_program_type" table to make sure that while 
> delete the tno in p_program_type,the p_schedule table would delete the data matching 
> p_schedule table.
> 
> create table p_schedule(
>        sche_no         int not null auto_increment,
>        cno             int not null,
>        prog_no         int not null,
>        start_time      datetime,
>        end_time        datetime,
>        index p_schedule_idx01 (cno),
>        foreign key (cno) references p_channel (cno),
>        index p_schedule_idx02 (prog_no),
>        primary key(sche_no),
>        foreign key (prog_no) references p_program( prog_no ),
>        foreign key (tno) references p_program_type(tno)
> ) TYPE=INNODB;

Take a look at ON DELETE clause:
        http://www.mysql.com/doc/en/InnoDB_foreign_key_constraints.html



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to