When terms are either updated or deleted in a terms store, respective records of deleted or old values in the database must be inspected for orphanism and cleaned up accordingly.
Old investigation stuff:
Best plan so far: create code in wikibase/term-store to clean up dead records and make it invokable from outside the library. Then create some maintenance script in Wikibase that invokes this code.
Because of the normalization we are ending up with unused records in the DB.
When the terms of a property are deleted, the records in property_terms are dropped. Referenced records in terms_in_lang are not dropped, etc.
How do we want to deal with these unused records?
1 Leave them be, no need to clean them up
- Con: wasted space in db (do we care?)
2 Have a maintenance script that periodically cleans them up
- Con: extra dev work
- Con: need to run extra script
3 Clean them up immediately
- Con: extra dev work
- Con: Write performance penalty
4 Clean them up post request with a job
- Con: most extra dev work
- Con: Write performance penalty (perhaps less severe then 3)
5 ???