Deleting Duplicate Facts in Mass


Quote from Tom Holden on 2021-07-01, 2:05 pmGood!
- Make a copy of your (.rmgc) database file and rename it, say, Old... so you can compare it with the result and have a fallback.
- Get a SQLite manager set up with a fake RMNOCASE collation, say SQLiteSpy and see RMNOCASE – faking it in SQLiteSpy #rmnocase #sqlitespy.
- Open your database file with the SQLite manager
- In its SQL editor, type or copy/paste:
REINDEX
;
CREATE TEMP TABLE OldEventTable AS
SELECT * FROM EventTable
;
CREATE TEMP TABLE NewEventTable AS
SELECT * FROM OldEventTable GROUP BY
EventType, OwnerType, OwnerID, PlaceID, SiteID, Date, Sentence, Details, Note
;
-- Uncomment to review the duplicates
--SELECT * FROM OldEventTable EXCEPT SELECT * FROM NewEventTable
;--empty the EventTable
DELETE FROM EventTable
;
INSERT INTO EventTable
SELECT * FROM NewEventTable
;- Execute above either one statement at a time or all at once, as you wish
- Now load and execute the script DeletePhantoms3.sql found at Delete Phantoms #database #delete #phantom
- Close the SQLite manager.
- Open the database with RM7 and run File>Database Tools>Rebuild Indexes and then Check Database Integrity. Repeat until OK.
- Inspect results.
I tested this on an old PLAY database and it turned up 39 duplicates.
Good luck!
Tom
Good!
- Make a copy of your (.rmgc) database file and rename it, say, Old... so you can compare it with the result and have a fallback.
- Get a SQLite manager set up with a fake RMNOCASE collation, say SQLiteSpy and see RMNOCASE – faking it in SQLiteSpy #rmnocase #sqlitespy.
- Open your database file with the SQLite manager
- In its SQL editor, type or copy/paste:
REINDEX
;
CREATE TEMP TABLE OldEventTable AS
SELECT * FROM EventTable
;
CREATE TEMP TABLE NewEventTable AS
SELECT * FROM OldEventTable GROUP BY
EventType, OwnerType, OwnerID, PlaceID, SiteID, Date, Sentence, Details, Note
;
-- Uncomment to review the duplicates
--SELECT * FROM OldEventTable EXCEPT SELECT * FROM NewEventTable
;--empty the EventTable
DELETE FROM EventTable
;
INSERT INTO EventTable
SELECT * FROM NewEventTable
; - Execute above either one statement at a time or all at once, as you wish
- Now load and execute the script DeletePhantoms3.sql found at Delete Phantoms #database #delete #phantom
- Close the SQLite manager.
- Open the database with RM7 and run File>Database Tools>Rebuild Indexes and then Check Database Integrity. Repeat until OK.
- Inspect results.
I tested this on an old PLAY database and it turned up 39 duplicates.
Good luck!
Tom

Quote from WKepley on 2021-07-01, 2:57 pmTom,
This looks way above my skill level. Would you possibly run this scrip on my file for a fee? Just asking...
Thanks,
BILL
Tom,
This looks way above my skill level. Would you possibly run this scrip on my file for a fee? Just asking...
Thanks,
BILL

Quote from Tom Holden on 2021-07-01, 3:21 pmSure. Email to my username at gmail.com or share it some other way.
Sure. Email to my username at gmail.com or share it some other way.


Quote from Tom Holden on 2021-07-01, 9:59 pmTo close the loop for others who may have been following, the attached image shows the database file properties before and after deleting duplicate events. There was a great amount of duplication and many unused citations et al. Together with the Delete Phantoms script, the database file was shrunk from 37MB to 21MB.
To close the loop for others who may have been following, the attached image shows the database file properties before and after deleting duplicate events. There was a great amount of duplication and many unused citations et al. Together with the Delete Phantoms script, the database file was shrunk from 37MB to 21MB.
Uploaded files: