I have a SQLite database of notes that have columns _id, title, details, listid
_id is the auto incremented primary key
title and details are string data fields
listid is a foreign key pointing to a list name in another table.
I’d like to find a way to have notes that are in multiple lists or notes that are linked in such a way that updating one will update the other or be edited simultaneously by some other means.
The overall goal is to have copies of the same note in multiple lists where you edit one and the rest update automatically.
I’ve thought of adding an extra column with a sort of link id that will be shared by all linked notes, creating a way to update other notes.
Have three tables:
Then whenever you add a note to a list, you add a new row to NOTES_IN_LIST that connects that note (‘s note_id) to the list (‘s list_id).
Whenever you edit a note, you just edit it in the NOTE table.
Whenever you list the contents of the list that you have the id for, you do a SELECT something like:
or
Hmm, to transfer old notes to new structure, I would:
Make sure noone edits or adds notes while this is happening, or you will lose notes.
Also you will need to update the UI to work into the new notes table, put notes to lists not by copying but by inserting a new row into NOTES_IN_LIST, etc.