I have two tables in the database:
- The table has a name and a column number number.
- Table 2 has a number number and a time column.
Now that the room number from the first column is removed or added, my second table should also be updated. I think this is possible with the TRIGGER command, but I'm not sure how to use it.
Typically, my database creation statement is as follows:
private static final String DATABASE_CREATE_PATIENT_ID_TABLE = "create table " + DATABASE_PATIENT_TABLE + " (_id integer primary key autoincrement," + "patient_number text not null, room_numbertext not null, " + "patient_initial text not null);";
Now that the rooms are deleted or added to the first table, my second table needs to be updated.
private static final String DATABASE_CREATE_NOTES_ID_TABLE = "create table " + DATABASE_NOTES_TABLE + " (_id integer primary key autoincrement," + " room_number text not null, time_hour text not null, " + "notes_hour text not null, today_date text not null);";
Initially, I was comparing the contents of two tables. But this will definitely lead to a performance issue later as the data grows. So I came across TRIGGER. I think this can solve my problem, but I donβt know how exactly I should use it.
I found out from Using SQLite Database with Android .
I explained this problem with a screenshot in another question. Please take a look at it, and if please, please help me a new question
Shaista naaz
source share