/* table 관계 설정이 되어 있는 경우 부모 테이블을 먼저 생성후 자식테이블을 생성해야 합니다. foreign key 설정이 되어 있는 테이블이 자식 테이블입니다 table을 삭제할때는 자식테이블을 먼저 삭제해야 합니다. */ /* st.sql - student */ create table st ( hakbun char(7) not null, name varchar(10) not null, tel varchar(14), address varchar(60), primary key(hakbun) )engine=innodb; /* kwamok.sql */ create table kwamok ( kwamok_code char(3) not null, kwamok_name varchar(20) not null, primary key(kwamok_code) )engine=innodb; /* sungjuk.sql */ create table sungjuk( hakbun char(7) not null, kwamok_code char(3) not null, jumsu int not null default 0, constraint foreign key(hakbun) references st(hakbun) on update cascade on delete restrict, constraint foreign key(kwamok_code) references kwamok(kwamok_code) on update cascade on delete cascade );