说我有以下内容:
CREATE TABLE activity_invites(
activity_id int(10),
activity_type varchar(5),
username varchar(50),
status int(1),
FOREIGN KEY(username) REFERENCES users(username)
ON DELETE CASCADE ON UPDATE CASCADE
)TYPE=INNODB;
假设事件被删除(事件表的事件),event_id ='1',我也想要这个activity_id ='1'和activity_type ='e'被删除的activity_invites表中的任何条目
像
这样的东西//somehow reference this only if activity_type = 'e'
FOREIGN KEY(activity_id) REFERENCES events(event_id)
ON DELETE CASCADE ON UPDATE CASCADE)
我唯一的选择是为每种类型的邀请创建一个表吗? (一个表格用于活动,帖子等。)