我正在制作 android 应用程序,其中我在一个开放的助手类中制作了 5 个表。当我的架构中有 ON DELETE CASCADE 时,我遇到了这个问题。我知道 ON DELETE CASCADE 的概念。在这里,我复制了两张表中的一张。
private static final String MEDICINE_TABLE = "create table medicine_details (_mid integer primary key autoincrement, "
+ " medicine_name text, type text, take_with text, m_did integer not null,"
+ "FOREIGN KEY(m_did) REFERENCES doctor_details(did)"
+ " ON DELETE CASCADE" + ");";
private static final String SCH_TAB = "CREATE TABLE schedule_details(sid INTEGER PRIMARY KEY AUTOINCREMENT, "
+ "medi_stdate TEXT,medi_end_date TEXT,time_sch TEXT,rept TEXT, alarm_id NUMBER, "
+ "u_id integer not null, doc_id integer not null, mid integer not null, "
+ "FOREIGN KEY(u_id) REFERENCES member_details(_id)"
+ " ON DELETE CASCADE,"
+ "FOREIGN KEY(doc_id) REFERENCES doctor_details(did)"
+ " ON DELETE CASCADE,"
+ "FOREIGN KEY(mid) REFERENCES medicine_details(_mid)"
+ " ON DELETE CASCADE" + ");";
每当我尝试从药物中删除时,它只会从药物表中删除,而不是从时间表表中删除。这里的医学表是主表,日程表是子表。