I have a database
that has three tables and there is a class_id column in all three tables. i want to when i deleting a class_id , Deleted all records in the tables that have the class_id
I used a way , but I'm not sure this way is standard or no ?
tip : class_id in a table is primary key and in another tables are foreign key
public void DeleteClass(int classId)
{
String query = "class_id = ?";
OpenDatabase();
database.delete(tblName_Class, query , new String[]{String.valueOf(classId)});
database.delete(tblName_Student, query , new String[]{String.valueOf(classId)});
database.delete(tblName_StudentPerformance , query , new String[]{String.valueOf(classId)});
close();
Toast.makeText(context, "deleted !", Toast.LENGTH_SHORT).show();
}