大概是一个租房管理系统,我要求的是
delete from house where houseName = ? 之后,可以级联删除与该houseName有关的内容
This is my tables building in java:
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
String sqlhouse = "create table house (houseName char(20) primary key, number int not null);";
db.execSQL(sqlhouse);
String sqlroom = "create table room(houseName char(20),roomNumber integer ,waterConsumption int not null"
+ ",electricityConsumption int not null,primary key(houseName,roomNumber),"
+ "foreign key (houseName) references house (houseName) on delete cascade on update cascade);";
db.execSQL(sqlroom);
String sqlrenter = "create table renter(Id char(18) primary key,name char(20) not null,phoneNumber char(11) not null)";
db.execSQL(sqlrenter);
String sqlcheckindocument = "create table CheckInDocument(Id char(18),houseName char(20),roomNumber int,deposit int not null,rental int not null,startingDate Date not null,surfing int not null,waterFare float not null,electricityFare float not null,totalAmount float,primary key (houseName,roomNumber),foreign key (Id) references renter(Id) on delete cascade on update cascade,foreign key(houseName,roomNumber) references room(houseName,roomNumber) on delete cascade on update cascade)";
db.execSQL(sqlcheckindocument);
String sqlcheckoutdocument = "create table checkOutDocument(houseName char(20),roomNumber char(10),checkOutDate Date not null,amount int,waterConsumption int not null,electricityConsumption int not null,"
+ "primary key (houseName,roomNumber),foreign key(houseName,roomNumber) references room(houseName,roomNumber) on delete cascade on update cascade)";
db.execSQL(sqlcheckoutdocument);
String sqlrentingdocument = "create table rentingDocument(houseName char(20),roomNumber char(10),waterConsumption int not null,electricityConsumption int not null,rentingDate Date not null,amount int not null,"
+ "primary key (houseName,roomNumber),foreign key(houseName,roomNumber) references room(houseName,roomNumber) on delete cascade on update cascade)";
db.execSQL(sqlrentingdocument);
}