Events – Add to all Children a Parent event shared with parents #facttypes #sharedevent #relationships #rm8

TBA: Rev 2021-03-0x above script adapted for RM8 by Tom Holden from the #RM7 script described below by the original author, Jerry Bryan. Note that the custom fact type ‘Parents’ and the role ‘Birth_of_Child’ must be created separately in advance of executing this script.

This is a query I wrote just for myself and I didn’t feel as if it were of sufficiently general interest to post here. Also, it is not as polished as I like queries to be that I share publicly. But a request came up on the RootsMagic forums, so here it is. The query adds a Parent fact to everyone in the database who is not a dummy person, who has parents, and who has a birth fact with a valid date. The dummy person definition is for my own database, where my dummy people have an asterisk somewhere in their name. The birth fact with a valid date is required because the Parent fact needs a valid date, and in my database at least it needs to be placed immediately after the Birth fact. The name of the fact is singular “Parent” but it supports both parents. As written, the parent information is placed two places: 1) in the Description field for the Parent fact, and 2) the Parent fact is shared with both parents.

My sentence template for the Parent fact itself is setup as follows:

<b>Parents:</b>< [Birth_of_Child].>

I use point form sentences with the sentence for each fact starting on a new line. The new line is a part of the template. Most RM users would need to set up the sentence template differently to meet their own needs. The [Birth_of_Child] variable looks funny, but that’s the role I share with the parents and it is what gets the parents listed in the sentence. Using the [Desc] variable would produce the same sentence, but using the [Birth_of_Child] variable causes the parents to be listed in the index for this page and the [Desc] variable does not. I mostly use Descendant Narrative reports. For the descendants, the parents appear in the report anyway, a generation earlier. The [Parent] variable makes the parents explicit. For the spouses of the descendant, their parents already appear by default in what I call the spouse sentence. So the [Parent] variable for the spouses represents a duplication. The spouse sentence is not under control of source templates (a major failing of RM), so I solve the problem by running a Notepad++ script on the RTF file to remove the parents from the spouse sentence before printing.

My sentence template for the [Birth_of_Child] role is as follows.

<b>Birth of Child:</b> <[Date:plain]><, [Person:Full]><, parent age: [ThisPerson:age:plain]>.

This has the salutatory effect of including the birth of each child on the timeline of each parent in a narrative report. Upon further review, I think the sentence would look better using a gender switch to say mother’s age or father’s age as appropriate. Gender switches work on the [Person] variable. I can’t remember if they work on the [ThisPerson] variable or not.

And here follows the script, warts and all

-- This script writ large creates a Parent
-- fact for every person in the RM database
-- who has parents. It loads the parents'
-- names into the Description field for the
-- Parent fact. It also shares the Parent
-- fact with the parents themselves where it
-- shows up as a Birth of Child event.
 
-- This script was not developed with the intent
-- of being generally distributed. Hence, it has
-- not been refined and tested the way I would do
-- for general distribution of a script. Please
-- use it and adapt it on an "as is" basis or for
-- ideas alone.
 
-- I can't remember for sure, but sometimes scripts
-- that insert this much data into into an RM data
-- base can create indexing errors. If so, run the
-- RM database tool in order immediately after running
-- this script.
 
-- Jerry Bryan 7/31/2018
 
 
-- Create a view of the EventTable
-- containing only Parents events.
-- This view will be used to prevent
-- creating a Parents event for
-- any individuals who already have
-- a Parents event. The main data needed
-- is the PersonID of the individuals
-- who already have a Parents event.
-- The PersonID manifests itself in
-- the EventTable as OwnerId.
 
 
DROP VIEW IF EXISTS ParentEventView;
CREATE TEMP VIEW ParentEventView AS
SELECT E.*
FROM EventTable AS E
       JOIN
     FactTypeTable AS FT  ON FT.FactTypeID = E.EventType
     WHERE FT.Name LIKE('Parents');
 
 
 
-- Create a view of the EventTable
-- containing only Birth events.
-- These events provides an initial list
-- of candidates of people to receive
-- a Parents event. Also, many of the
-- fields for newly created Parents
-- events will be replicated from the
-- corresponding Birth event.
 
DROP VIEW IF EXISTS BirthEventView;
CREATE TEMP VIEW BirthEventView AS
SELECT Birth.*
FROM EventTable AS Birth
       JOIN
     FactTypeTable AS FT  ON FT.FactTypeID = Birth.EventType
     WHERE FT.Name LIKE('Birth');
 
 
-- Create a view of Birth events for people
-- that don't have a Parent event. This is the
-- first filtering on the list of candidates
-- of people to receive a Parents event.
 
 
DROP VIEW IF EXISTS BirthWithoutParentsEventView;
CREATE TEMP VIEW BirthWithoutParentsEventView AS
SELECT Birth.*
FROM BirthEventView AS Birth
          LEFT JOIN
     ParentEventView AS Parent ON Parent.Ownerid = Birth.OwneriD
WHERE Parent.OwnerID IS NULL;
 
-- Create a view of the NameTable
-- containing only primary names.
-- This view will be a source of
-- the names needed for the newly
-- created Parents events and will
-- prevent any names other than the
-- primary ames from being loaded
-- into -- Parents events. This
-- view also prevents Parents events
-- from being created for any dummy
-- people, designated with an asterisk
-- in the name.
 
DROP VIEW IF EXISTS NameView;
CREATE TEMP VIEW NameView AS
SELECT N.*
FROM NameTable AS N
WHERE N.IsPrimary = 1
  AND N.Surname NOT LIKE('%*%')
  AND N.Given   NOT LIKE('%*%');
 
-- This view performs most of the
-- main processing for this project.
-- It determines which people actually
-- do have parents. Actually having
-- parents is based on being in the
-- ChildTable and has nothing to do
-- with whether a Parents event exists
-- or not. This list of people with parents
-- is then matched against people who are not
-- dummy people, who do have birth
-- events, and who don't already have
-- Parents events. This view also
-- develops the data that will need to
-- be stored in the newly created
-- Parents events.
 
 
DROP VIEW IF EXISTS ChildParentsView;
CREATE TEMP VIEW ChildParentsView AS
SELECT Child.ChildID,  Child.Given  || ' ' || Child.Surname  AS ChildName,
       Father.FatherID, Father.Given || ' ' || Father.Surname AS FatherName,
       Mother.MotherID, Mother.Given || ' ' || Mother.Surname AS MotherName,
       CASE
       WHEN Father.FatherID = 0 THEN Mother.Given || ' ' || Mother.Surname
       WHEN Mother.MotherID = 0 THEN Father.Given || ' ' || Father.Surname
       ELSE Father.Given || ' ' || Father.Surname || ' and ' || Mother.Given || ' ' || Mother.Surname
       END CombinedNames,
       B.Date,
       B.SortDate,
       B.EditDate
 
FROM  (  SELECT C.RecID,
                C.ChildID,
                N.Given,
                N.Surname
         FROM   ChildTable AS C
                  JOIN
                NameView AS N ON N.Ownerid = C.ChildID
      ) AS Child
 
           JOIN
 
      (  SELECT C.RecID,
                FM.FatherID,
                N.Given,
                N.Surname
         FROM ChildTable AS C
                JOIN
              FamilyTable AS FM ON C.FamilyID =  FM.FamilyID
                LEFT JOIN
              NameView AS N ON N.OwnerID = FM.FatherID
      ) AS Father ON Father.RecID = Child.RecID
 
           JOIN
 
      (  SELECT C.RecID,
                FM.MotherID,
                N.Given,
                N.Surname
         FROM   ChildTable AS C
                  JOIN
                FamilyTable AS FM ON C.FamilyID =  FM.FamilyID
                  LEFT JOIN
             NameView AS N ON N.OwnerID = FM.MotherID
       ) AS Mother ON Mother.RecID = Father.RecID
 
            JOIN
 
       BirthWithoutParentsEventView AS B ON B.OwnerID = Child.ChildID;
 
-- The data from the ChildParentsView needs to be used
-- twice, once to load Parents events into the EventTable
-- and again to load roles into the WitnessTable. The
-- Parents events have to be loaded into the EventsTable
-- first, and one Insert statment in SQLite cannot load
-- data into two tables. However, loading Parents Events
-- into the EventTable will cause the ChildParentsView
-- not to produce the correct results the second time it
-- is used. Therefore, the results from applying the
-- ChildParentsView will be saved into a temporary table
-- called ChildParentsTable. As a table instead of a view,
-- the data in ChildParentsTable can be used two different
-- times and remain the same data both times it is used.
 
DROP TABLE IF EXISTS ChildParentsTable;
CREATE TEMP TABLE ChildParentsTable
(ChildID,ChildName,FatherID,FatherName,MotherID,Mothername,CombinedNames,Date,SortDate,EditDate);
INSERT INTO ChildParentsTable
(ChildID,ChildName,FatherID,FatherName,MotherID,Mothername,CombinedNames,Date,SortDate,EditDate)
SELECT CP.*
FROM ChildParentsView AS CP;
 
 
 
-- Load new Parents facts into the EventTable.
 
INSERT OR ROLLBACK INTO EventTable
SELECT NULL AS EventID
    ,(SELECT FT.FactTypeID FROM FactTypeTable AS FT WHERE FT.Name LIKE('Parents') ) AS EventType
    ,0 AS OwnerType
    ,ChildID AS OwnerID
    ,0 AS FamilyID
    ,0 AS PlaceID
    ,0 AS SiteID
    ,Date AS Date
    ,SortDate AS SortDate
    ,0 AS IsPrimary
    ,0 AS IsPrivate
    ,0 AS Proof
    ,0 AS STATUS
    ,EditDate AS EditDate
    ,CAST('' AS TEXT) AS Sentence
    ,CAST(CombinedNames AS TEXT) AS Details
    ,CAST('' AS TEXT) AS Note
 FROM ChildParentsTable;
 
 
 
 --   ===========================================================================================================
 --     The following is adapted from Tom Holden to rank same date sort dates.
 --
 --     There are a number of changes by Jerry Bryan that are specific to his
 --     use case.
 --
 --        * The list of fact types which are supported is greatly increased.
 --        * Sort dates including ranked sort dates (date-n) are ranked and even re-ranked
 --          whether or not they match the date from from the fact itself, provided only
 --          that the sort dates in question match each other.
 --             . This allows same "ABT" dates to be ranked.
 --             . This allows same "year only" dates to be ranked if the sort date is
 --               1 July of the year.
 --             . This allows same "year and month only" dates to be ranked if the
 --             . sort date is the 15th of the month.
 --
 --   ===========================================================================================================
 
/* SortDateSameDayOrderCustom.sql
   2011-12-20 ve3meo
   Alters SortDates of any set of Fact types
   to a natural order when any pair or more occur on the same date.
   Could be extended to order other facts also. SortDates are effectively assigned
   (by arithmetical offsets) an absolute suffix -1, -2, ... related to the rank of the FactType.
   Affects only those events whose SortDates correspond to the Fact Date, as computed
   by a Date encoding algorithm. The algorithm does not handle Date modifiers so not all
   Event dates are handled, e.g. "Bef 1960".
*/
DROP TABLE IF EXISTS TmpFactOrder
;
CREATE TEMP TABLE IF NOT EXISTS TmpFactOrder
(Rank INTEGER PRIMARY KEY, FactName TEXT)
;
 
/* list of Fact Names, standard and custom, to be sorted, in rank order.
   Revise the list to suit your needs */
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Birth');
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Parents');             -- added by JB
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Birth Certificate');   -- added by JB
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Christen');
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Baptism');
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Death');
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Obituary');            -- moved up by JB
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Death Certificate');   -- added by JB
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Funeral');
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Cremation');
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Burial');
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Burial Inscription');  -- Added by JB
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Burial GPS');          -- Added by JB
INSERT INTO TmpFactOrder (Rank, FactName) VALUES (NULL, 'Memorial');
/* revise SortDates */
UPDATE EventTable
SET SortDate = SortDate
  -6692012023  -- this offset goes to Date-1 if the event is a ranked event
  *( (
      SELECT Rank
      FROM TmpFactOrder,
           FactTypeTable
      WHERE FactName LIKE Name
      AND FactTypeID = EventType
      )>0
    )
  +1048576  -- this offset adds steps of 1 to Date-1 multiplied by (rank-1)
  *( (
      SELECT Rank
      FROM TmpFactOrder,
           FactTypeTable
      WHERE FactName LIKE Name
      AND FactTypeID = EventType
      )-1
    ) -- maps the FactType to its order
WHERE EventID
IN (SELECT EventID FROM EventTable
    INNER JOIN
    (SELECT -- matching dates
     SortDate, OwnerID, COUNT()-1 AS Matches
     FROM EventTable
     INNER JOIN FactTypeTable
     ON EventType = FactTypeID
     WHERE EventTable.OwnerType = 0
     AND Name IN (SELECT FactName FROM TmpFactOrder)
/*     AND    -- commented out by JB to handle sort dates not matching fact date when sort dates are equal to each other.
     SortDate =   -- equals encoded event Date (if not a match, suggests that user has modified SortDate so don't touch it)
       (CASE
        WHEN DATE LIKE '.%'
        THEN 1
        ELSE Substr(DATE,3,5) END
        +10000
        )*562949953421312
        + Substr(DATE,8,2)*35184372088832
        + Substr(DATE,10,2)*549755813888
        + 17178820620 */
      GROUP BY SortDate, OwnerID, EventTable.OwnerType
     )
     USING (OwnerID, SortDate)
     INNER JOIN FactTypeTable
     ON EventType = FactTypeID
     WHERE Matches
     AND EventTable.OwnerType = 0
     AND Name IN (SELECT FactName FROM TmpFactOrder)
    )
;
 
 
-- We now add Parent roles to each Parents event.
-- It is most convenient to add the Parent role
-- for the father in one INSERT and to add the
-- Parent role for the mother as a separate insert.
-- So we first create a view that joins the
-- Parent events with the ChildTable and FamilyTable
-- to get a list of Parent events and their
-- respective fathers and mothers.
 
DROP VIEW IF EXISTS ParentRoleView;
CREATE TEMP VIEW ParentRoleView AS
SELECT PEV.*,
       FM.FatherID, FM.MotherID
FROM ParentEventView AS PEV
        JOIN
     ChildTable AS CT ON CT.ChildID = PEV.OwnerID
        JOIN
     FamilyTable AS FM ON CT.FamilyID =  FM.FamilyID;
 
 
-- Load Parents roles for fathers into the WitnessTable
 
INSERT OR ROLLBACK INTO WitnessTable
SELECT NULL AS WitnessID
    ,PE.EventID AS EventID
    ,Parents.FatherID AS PersonID
    ,0       AS WitnessOrder
    ,(SELECT R.RoleID FROM RoleTable AS R WHERE R.RoleName LIKE ('Parent') ) AS Role
    ,CAST('' AS TEXT) AS Sentence
    ,CAST('' AS TEXT) AS Note
    ,CAST('' AS TEXT) AS Given
    ,CAST('' AS TEXT) AS Surname
    ,CAST('' AS TEXT) AS Prefix
    ,CAST('' AS TEXT) AS Suffix
 FROM ChildParentsTable AS Parents
         JOIN
      ParentEventView AS PE ON PE.OwnerID =  Parents.ChildID AND PE.Details = Parents.CombinedNames;
 
-- Load Parents roles for mothers into the WitnessTable
 
INSERT OR ROLLBACK INTO WitnessTable
SELECT NULL AS WitnessID
    ,PE.EventID AS EventID
    ,Parents.MotherID AS PersonID
    ,0       AS WitnessOrder
    ,(SELECT R.RoleID FROM RoleTable AS R WHERE R.RoleName LIKE ('Parent') ) AS Role
    ,CAST('' AS TEXT) AS Sentence
    ,CAST('' AS TEXT) AS Note
    ,CAST('' AS TEXT) AS Given
    ,CAST('' AS TEXT) AS Surname
    ,CAST('' AS TEXT) AS Prefix
    ,CAST('' AS TEXT) AS Suffix
 FROM ChildParentsTable AS Parents
         JOIN
      ParentEventView AS PE ON PE.OwnerID =  Parents.ChildID AND PE.Details = Parents.CombinedNames;
;
 

DAT File Question #ancestrycom #treeshare #database

I found some discrepancies in RootsMagic and posted a question. This was in an answer:

C:\Users\Tom\AppData\Roaming\RootsMagic\AMT (change the “Tom ” to your Windows username). In this folder is a .DAT file for each connected Ancestry Member Tree (AMT), named “AT-AncestryTreeID.DAT”, where AncestryTreeID is an integer. This file is a SQLite database containing tables named identically to a subset of the TreeShared RM database file.

Is there any data description documentation on that file? Or any documentation on its purpose in life and what it does.

Discussions & comments from Wikispaces site


ve3meo

 

Very preliminary answer

ve3meo
26 July 2018 14:26:47

Nothing published. Your description is accurate. We surmise that it is created by TreeShare, contains relationships between RM items and Ancestry items that are sync’d. It might be an intermediate file that TreeShare creates before transmitting changes in one or the other directions.

GEDCOM & DnD transfer losses #gedcom

Background

RM10 reportedly uses direct data transfer between databases for drag’n’drop, not GEDCOM, so it will have different issues, if any. 2024-06-20

RootsMagic Drag’n’Drop between the windows of two databases is a background GEDCOM export-import process. Both Drag’n’Drop and the explicit File>Export and Import process fail to fully transfer everything from one database to another. Drag’n’Drop and GEDCOM are governed by the settings for Export in Lists>Fact Type List so any fact type that is not enabled for “Exporting GEDCOM files” will be lost in transfer. A number of other less obvious losses have been identified Continue reading →

RMNOCASE – faking it in SQLite Expert, command-line shell et al #rmnocase

SQLite Expert now takes the lead as the most compatible with the RootsMagic RMNOCASE collation, thanks to the C extension unifuzz.dll authored or revised by Jean-Christophe Deschamps. Unifuzz can be used with other SQLite managers that support extensions, including the command-line shell sqlite3.exe but not, regrettably, SQLiteSpy.

This is not simply a renamed equivalent of the SQLite NOCASE collation (see RMNOCASE – faking it in SQLiteSpy); rather, it is a very comprehensive compilation of the unicode character set. Against a RootsMagic database comprising 8091 different Unicode characters in Surnames, PRAGMA Integrity_Check returns 187 missing rowids from indexes idxSurname and idxSurnameGiven with SQLite Expert using this substitute collation. SQLiteSpy returns 16042 missing rowids from the same two indexes including 9 from idxSourceTemplateName with its fake collation. RootsMagic itself reports two missing rowids from each of the two Person Name indexes so there is something wrong even with the genuine RMNOCASE collation.

Download unifuzz.dll, unifuzz64.dll

unifuzz.dll or unifuzz.dll.bak (for 32-bit apps. Remove .bak extension after d/l, added due some systems’ security)

unifuzz64.dll for 64-bit apps, added 2020-03-05, tested with SQLite Expert Personal 64bit 5.3.5

Download and save to the same folder where you have the executable file for SQLite Expert or the command-line shell (or other SQLite manager that supports C extensions).

Using unifuzz.dll with SQLite Expert

Version 3.5

  1. Under the menu item Tools > Options > Show/Hide Features, check the box labelled “Load/Unload Extensions” to reveal these selections in the File menu. The options is saved between sessions.
  2. To load the extension, simply select File > Load Extension and use the resulting “Select extension file” window to browse to, select and open unifuzz.dll. OK the default value “sqlite_extension_init” in the Entry Point window. That’s it! You now have a very (if not perfectly) compatible RMNOCASE collation associated with the database.

Version 4 and 5

The Show/Hide Features option is missing from this version as is File > Load Extension. The only choice is to right-click on the database name in the sidebar to invoke the drop-down menu which includes Load Extension and proceed as in step 2 for ver 3.5. Because unifuzz.dll is a 32-bit extension, it will work with only the 32-bit version of SQLite Expert. Use unifuzz64.dll with the 64-bit version. The Unload Extension function is inoperable and there is no way to tell if an extension has been loaded.

There is a functional difference between the free SQLite Expert Personal edition and the $59 Professional edition. Personal requires that you load the extension for each database, each time you open the database while Pro can be set to automatically load an extension. The free SQLiteSpy can be set to auto load an extension but can only have one main database open at a time while Expert can have multiple databases open.

Using unifuzz.dll with SQLite3.exe

This C extension can be used with the command line shell, which opens up some potentially powerful possibilities with Windows command scripts (batch files). To load the extension, from the SQLite prompt enter the dot command:

sqlite> .load "unifuzz.dll"

If SQLite3.exe and unifuzz.dll are not in the same directory, then the full path to unifuzz.dll must be provided between the quotes.

The shell can be launched to execute a sql script to both load this “RMNOCASE” extension and run sql commands – here’s a simple example. At the Windows command prompt, open on the folder where the database file, sqlite3 and unifuzz are all located, enter the following or open a batch command file with the same content:

sqlite3 "RootsMagic database filename with .rmgc extension" < "sql script filename"

Example SQL script file to be called from the command line:

.LOAD "unifuzz.dll"
 
/*
 demonstrate that RMNOCASE is available by returning list of surnames
 - if not available, an error is returned
*/
 
SELECT Surname FROM NameTable ORDER BY Surname;

Unifuzz.c Source and compiling

unifuzz.c is readily compiled using the gcc compiler, mine came bundled in Dev-C++ Integrated Development Environment. I couldn’t figure out how to tell the IDE what I wanted to do but Jean-Christophe provided the command line for the gcc compiler at line 541 of his source code so I followed that. As the source is written, you want to extract to a folder the sqlite3.h and sqlite3ext.h files from the zip or tar file named sqlite-amalgamation-versionnumber on the SQLite Download Page under the heading Source Code. In a sub-folder below those .h files, place the unifuzz.c file. Then in the command line interface, issue:

pathtogcc\gcc -O2 -lm -shared unifuzz.c -o unifuzz64.dll

The DLL file will be produced in the same folder as the unifuzz.c file.

Discussions & comments from Wikispaces site


mooredan

unifuzz run time loadable extension for OS’s other than Windows

mooredan
05 September 2017 00:54:38

Hooray! This has been on my ToDo list for a long time and I finally worked on this this weekend. As mentioned above, being able to run queries from the command line opens up a host of powerful possibilities. Unfortunately, the provided DLL above only works on Windows. I run RootsMagic on macOS, but macOS being Unix-like based, the sqlite3 command line tool can be compiled and used. If you try to run a query without accommodating for RMNOCASE, you get the dreaded “Error: no such collation sequence: RMNOCASE” message. Long story short, this is now working on my MacBook Pro. The details can be found here: https://github.com/mooredan/unifuzz . This should work for a Linux system as well. If someone wants a binary, let me know if you don’t want to (or can’t) roll your own.

I hope to integrate this with PHP and GD for creation of some custom web-based charts….


momakid

momakid
20 September 2017 22:14:45

I installed SQLite Expert Personal (5.2 (x64).
I opened my RootsMagic database.
I entered the following in the SQL window:
select surname
from nametable;
I got no such collation sequence: RMNOCASE

I did a right click on my database
I selected Load Extension
I selected the the File Name (C:\Program Files\SQLite ExpertPersonal 5\unifuzz.dll)
I entered sqlite_extension_init for the Entry Point
I left auto unchecked
I clicked OK
I got a popup of The specified module could not be found

Facts – Change Fact Type #facttypes #events #rm8

Problem

RootsMagic provides no means to change all events of one fact type to another fact type, e.g., convert Residence events to Census events or vice versa. Or convert events for a custom fact type to a standard one. All it offers as of version 7.6.3 is to do so for one person, one event at a time which is laborious and slow.

Solution

A script that converts all events of one fact type to another in a fraction of a second.

Usage

Copy the value of the Abbreviation variable for the Fact Type of interest from the Fact Type List (or from the fact name as seen in the Edit Person screen)

Enter the name of the current event as you see it in the Edit Person screen or as you see it in the Abbrev field of Lists > Fact Type List. Then the value of the Abbrev field for the fact type to which you want the events transformed. When entered, the UPDATE process proceeds.

First of two run-time parameters to be entered to change all events of one fact type to another. Enter the value exactly as found in the Abbreviation field for the Fact Type of interest. Screen clip from SQLite Expert Personal.

Requires SQLite Expert Personal with fake RMNOCASE extension loaded or an equivalent SQLite manager that also supports the entry of runtime variables.

Because this modifies your database, BACKUP FIRST! After executing, you should use RootsMagic Database Tools to check integrity and, if not OK, rebuild indexes.

Scripts

Two scripts are offered: one is for only for a fact type having no shared events and is simpler and faster. The other supports conversion of a fact type that does have shared events; use it if you are uncertain but you can check for shared events with the help of People Who Share a Fact with a Principal List and with People Who Share A Fact with a Principal, But Who Are Not in a Tree in The File List.

2021-12-30: Facts_shared-ChangeType-RM8.sql for #RM8. 
 Facts_shared-ChangeType.sql for prior versions.
These much more complex scripts than Facts-ChangeType.sql below do support shared events in addition to unshared ones. 

Facts-ChangeType.sql This simpler script than the ones above can change the Fact Type of unshared events but not shared events. 2023-03-14: protects shared events from being changed and tested compatible with #RM9. Should be compatible right to RM4.

For the conversion of shared events, the more complex scripts look for role(s) in the target fact type that match the name and sentence template of those used by events of the originating fact type. For those that do not match, a duplicate of the current role is created for the target fact type. Sharers of the transformed event are assigned these existing or new roles. The original role definitions remain intact. Should events be converted back to their original fact type, no new roles will be created provided no change has been made in either the original or target role name or sentence.

Discussions & comments from Wikispaces site


anni628

Newbie successfully used this!

anni628
25 July 2017 18:33:32

Have never touched SQLite before today (although I do have a somewhat minimal exposure to programming) but was able to piece together the proper program, with the proper fake RMNOCASE extension, and the above script (after a couple of false starts) and within two hours from start to finish had successfully modified my RootsMagic database that was imported from FTM 2014.

I didn’t like the way the import put the FTM Description fields on major facts (Birth, Baptism, Marriage, Naturalization, Death, Burial, Probate) into Place details so, before the import, I used the built-in FTM option to move all those facts to corresponding temporary facts (TBirth, TBaptism, TMarriage, TNaturalization, TDeath, TBurial, TProbate). Imported the file to RootsMagic and used the above script to move all the data back to the original fact. Worked like a charm. I ran the Database tools after and everything worked splendidly. On 18,165 people tree. Would have taken years to do this manually person by person which is the only option within RootsMagic.

Have spot checked people and everything, including the more complex shared marriage fact is functioning exactly as they should.

Thank you Tom! Wish I had tried it back in Jan of 2016 instead of continuing with FTM but I guess things happen at the time they are meant to happen.

TreeShare – Rename Cryptic Filenames for Citation Media #TreeShare #media #citations #batch

TreeShare downloads Ancestry media for citations with cryptic file names that mean nothing to humans. This set of scripts and batch or command-line operations prepends to the media filenames the name of one of the persons to whom the citation applies, their BirthYear-DeathYear and the name of the source cited, separated from the cryptic name by the @ symbol. Such information in the file names can help the user organise the downloaded media into folders by surname or even more finely divided. Renaming the files has no apparent effect on TreeShare operations.

A variant of the script could change the order in the new name to be source name first, which would aid in finding and reorganising by source, rather than by person.

Here is a screenshot showing results from a temporary table created by the second script which lists the Ancestry name (OldName) with its new, informative name.
Tree_Share-_Media_Rename_Old_New_Spy.png

Here is a screenshot of a Media Gallery after the files have been renamed.
Tree_Share-_Media_Rename_Media_Gallery_Snap.png
Note that the source was cited to four facts or events about the person. and could be cited for multiple facts for multiple people, as, for example, a Census source and image could be tagged to Birth and Residence facts for all family members. However, there is only one image file for that source so the procedure takes the person and event last cited for use in the file name.

As always, use these tools at your own risk. I cannot predict all possible consequences. I saw no adverse effect in my one test case.

READ the comments at the beginning of each script and the instructions at the end, which will also be displayed on completion of the script execution. DO NOT CLOSE THE DATABASE IN THE SQLITE MANAGER UNTIL YOU NO LONGER WISH TO UNDO.

TreeShare-MediaRenameStep1.sql This script can do no harm. It is a variation of RM7_5-WaymarksViews.sql to revise the format and content of some of the Waymarks to suit this application. It generates a set of temporary SQLite Views with which one can inspect the contents of a table and from the Waymark info, navigate within RootsMagic to see where a record is used. For this application, it also generates a temporary table zMediaCitationTags needed for the following script.

TreeShare-MediaRenameStep2.sql Changes the media links so they will appear broken in the Media Gallery until you successfully rename the files with the batch commands it generates.

TreeShare-MediaRenameUNDO.sql Changes the media links back and generates batch commands for changing the media file names back to their Ancestry original.

Possible risks:

  1. A new filename might exceed the limit supported by the file system. Didn’t happen in my test case and would require very long Ancestry file name, source name, person name (couple events would be worst case).
  2. There is a character in one of the names that is invalid for a file name. Didn’t happen.
  3. Some RootsMagic operations may be locked out by having the database open in the SQLite manager and some may lock out the SQLite manager. Avoid doing a backup or using the RM Database Tools while in session on the SQLite manager. I’ve not had a problem while in TreeShare or main views and Edit Person. I’d be wary about going into FamilySearch Central and perhaps having WebHints on.

TMG-RootsMagic Split Citation Details #tmg #citations #sourcetemplates

RootsMagic 6.3.3.2 imports TMG Citation Detail memo field into CitationTable.Fields as the field [CD] defined in the SourceTemplateTable.Fields regardless of TMG memo splitter “||”. An issue which I’m sure many will detect is that sentences for sources with split Citation Detail (CD1, CD2,..) do not contain any of the Citation Detail. The full value is there in the [CD] field but the sentence templates use [CD1] etc, not [CD]. A fix is to manually edit the Source Template sentence templates to use [CD] in the sentences – there are only 3 or 4 such source templates in the Sample Project – however that changes the order and lengthens the Short Footnote and the || separator remains in the output. A much better result is to add [CD1] et al fields to the source template field definitions and then edit each citation to separate the pieces out of [CD] into the new fields. Unfortunately, every citation needs to be edited – for some users this may number in the thousands or even tens of thousands.

I’m hopeful that the RootsMagician will find the resources to automate this parsing and mapping on import. Meanwhile, here is a SQLite procedure which does the job for those Citations having footnote sentences using [CD1] and [CD2], the most common case where the Citation Detail memo is split into two parts. It splits and replaces [CD] in CitationTable.Fields into the two parts [CD1] and [CD2]. It splits and replaces Citation Detail [CD] in the fields definition in SourceTemplateTable.Fields for the source templates used by these citations. NEW! Script now handles up to CD9…2014-09-30.
.

Citation_TMGimportsplitbefore.png
Citation imported from TMG before running the query. Note the absence of any Citation Detail content in the preview of the Footnote, Short Footnote sentences and the “||” splitter in the Citation Detail value.
Citation_TMGimportsplitafter.png
After running the query, the sentences contain the values from the split Citation Detail, now replaced by [CD1] and [CD2].

Citations_TMGimport_splitCDtoCD1-9.sql
This query needs the REGEXP function available in SQLiteSpy. but not in SQLite Expert Personal.

As usual, backup first. Be sure to inspect for adverse effects; I have checked various combinations but, obviously, cannot anticipate all the possible variations that can arise from many different users.

TMG-RootsMagic Sentence Variables & Format Codes #tmg

RootsMagic version 6.3.2.0 and later supports the direct import of project databases from The Master Genealogist. These programs have many similarities and, of course, many differences. They both support witness tags/shared events, sentence templates for facts, footnotes and bibliography and text formatting but names of variables, syntax, codes and database structure differ. Not all can be converted: some codes are stripped and others pass through verbatim. This page offers two resources to help in the resolution of some of the differences in codes between the TMG database and the resulting RootsMagic database.

TMG-RootsMagic Sentence Variables & Format Codes

This document attempts to provide a cross-reference to help in the transition of a TMG database to RootsMagic. The TMG emigre will almost certainly need to edit the imported database or the original to achieve the most complete transfer of data and the cleanest reports and other outputs. Having a cross-reference between their codes with an explanation of their functional similarities and differences should help.

TMG_Roots_Magic_Sentence_Variables_Format_Codes.png
Screenshot of 1 of 17 pages.

Download 1

TMG-RootsMagic Sentence Variables & Format Codes (PDF)

Finding Extant TMG Codes

The following query finds those fields in the imported RootsMagic database that still have embedded TMG codes. A power SQLite user might go on to edit the database using a SQLite manager. A normal RootsMagic user can inspect the results for the passed through codes and use the key characteristics in a RootsMagic Search tool to find them. With the help of the above cross-reference and other yet-to-be-devised resources, either can determine whether action is best taken in the original TMG file and re-import or modify the RootsMagic data. It also may reveal a bug worth reporting to RootsMagic Technical Support.

Check_TMGimportfor_Codes_sql.png
Screenshot of results of query on the TMG Sample Project imported into RootsMagic. The full content of the highlighted row is displayed at the bottom, revealing the “||” separator in the Citation Detail (CD) field.

Download 2

CheckTMGimportforCodes  2014-09-25 rev to include Event custom sentences; exclude blank values for speedup

This query requires the REGEXP function, available in SQLiteSpy but not the free version of SQLite Expert. If this is your first time using SQLite on a RootsMagic database, please visit the Home page and read How to query RootsMagic and SQLite Managers.

TMG-RM Convert TMG_ID to Reference Number #tmg #refno

RootsMagic 6.3.2.0 imports the TMG_ID into a custom fact type TMG_ID. This fact type cannot be displayed after the name of the person. Some users
would prefer that it did, either by having it as RIN or by a new feature specifically for TMG. (See also TMG-RM Convert TMG_ID to Record Number)

This procedure makes a clone of the TMG_ID as a Reference # fact which can optionally be displayed after the name. The virtue of both the TMG_ID custom fact and the Reference Number fact is that they are non-volatile when transferred or imported into other databases, unlike RIN.

Because multiple REF# facts are allowed for each person, only the REF# with the lowest record number in the EventTable is displayed. Therefore the procedure also relocates pre-existing REF# facts to the end of the table.

N.B. Be sure to close the database from RM before running this procedure
Otherwise, for some arcane reason, adding most any fact edits one of these new REF# facts, until the database has been closed and reopened.
Probably, some last record number register in the program has to be updated.

TMG_RM_convert_TMG_IDto_Ref_Num.png
Sample project imported from TMG after running SQLite procedure. TMG_ID now displayed on the main screen via option to use Reference Number after the name for displays and reports. The Sidebar only shows RIN or no suffix.

TMG-RM_convertTMG_IDtoREF.sql

TMG-RM Check for False Spousal Event Sentences #tmg

TMG has dual Principal, non-spousal events that RM does not support. Direct import converts these events to Individual type and variables of
Spousal type may get through, i.e., [Spouse], [Husband], [Wife], which are invalid for a RM Indiv event. The name of the variable is outputted instead of nothing when it is unrecognised for a type of event.

This query finds occurrences of these spousal name variables in the Sentence fields of the FactTypeTable, EventTable, RoleTable and WitnessTable. With the name of the table and its ROWID, one could edit the sentence directly from the SQLite manager. The Name of the record where the sentence is defined and the Where value will help find the sentence using RootsMagic to edit and inspect results of changes.

TMG_RM_False_Spousal_Event_Sentences.png
TMG-RM_FalseSpousalEventSentences