[Database] 외래키 사용

Yeon Jeffrey Seo·2022년 4월 20일
0

데이터베이스

목록 보기
4/6
create table item_option(
	id INT PRIMARY KEY AUTO_INCREMENT, 
	item_id INT,
    option_id INT,
	FOREIGN KEY(item_id) REFERENCES items(id) ON UPDATE CASCADE ON DELETE SET NULL,
	FOREIGN KEY(option_id) REFERENCES options(id) ON UPDATE CASCADE ON DELETE SET NULL
);
alter table tb_schedule_users 
add constraint merchantUser_scheduleUser 
foreign key (userId) 
references tb_merchant_user(id) 
on update set null 
on delete set null;
profile
The best time to plant a tree was twenty years ago. The second best time is now.

0개의 댓글