When working with data, you may realize that you have more than one record for the same entity – for example the same person or event was entered twice.
In the case of a duplicate record – you have two records with the exact same information – you can simply delete one of the records. However, sometimes you may find different information in the two records, and you want to combine them into a single, new record. This is when you use the Merge button to take data from one or more records, transfer it to a new record, and then delete any redundant records.
To look at a simple example, I’ve created a few example events, two of which have similar names but different data.
To merge “event 2” and “event2,” start by selecting these two records.
The Merge button is now active and shows in parentheses that two records have been selected. Clicking the Merge button pops up a new screen with an empty column on the left and the selected records on the right. Click the arrow next to the data to move it into the new record. This is the data that should be kept from each record. In the example, the new record is named “event 2” and has a start date of “1901.”
The identifier in the top row assigned by Core Data and is what’s called a UUID, or universally unique identifier. This alphanumeric combination is how Core Data stores records, so even if you change the name or other data, the record is saved under a consistent id.
You can assign an existing UUID to the new record by moving one over from either Record 1 or Record 2. Alternately, if you leave that field blank, the new record will have be assigned another UUID. In this case, the field is blank.
Double check that the first column has all of the data that should be kept before clicking Merge because this action cannot be undone, and Record 1 and Record 2 will be deleted. You will have a chance to confirm the Merge.
When you open your newly created record, you’ll find new entries in the Merges section. This shows the records of the UUIDs that were merged into this record. It is possible to delete this history, in which case the UUIDs are removed.
All associations are included in a merged record, so if A is merged into B and A has an association to record C, B now has that association with C.