I know this should be straight forward, but somehow I seem to struggle.

Importing a child-parent relationship.

I have 10 children records (External ID, Child Name, Child Surname) and 5 parent records (Parent Name, Parent Surname, Parent Mobile Number, Subtype).

I used https://dmaster.demo.civicrm.org to import the 10 children records first. I then did another import for the 5 parent record:

I got an error message: External ID already exist in the database

So, 0 records were imported.

So, I tried again. This time I selected Update for For Duplicate Contacts

According to the message, 20 records were created or updated. Thus, I ended up with 20 records.

I thought that there should be 15 records. For example, if parent A has two children (Child 1 & 6), then there should only be one record for Parent A and when we click on Parent A, it should show that Parent A is the parent of Child 1 and Child 6.

At the moment there are two records of Parent A. When you click the one record it shows that Parent A is the parent of Child 1 and when you click on the other record of Parent A, it shows that Parent A is the parent of Child 6. The following are the records for the Parents:

When I selected Fill for For Duplicated Contacts, 20 records were created or updated.

Any guidance will be provided or should it be 20 records.

  • also note you should be able to create the children and the parents in the same import
    – petednz - fuzion
    Commented Jul 9, 2020 at 19:55
  • Hopefully this is test data - no real contact data should be posted here.
    – Aidan
    Commented Jul 10, 2020 at 10:31
  • @petednz-fuzion, It appears to be the case as explained Commented Jul 11, 2020 at 16:19
  • @aidan, I have removed the information. Even though I mixed it up, some information was recognisable. Thanks. Commented Jul 11, 2020 at 16:19
  • @pietpompies just so you are aware the original question is still available in the revision history civicrm.stackexchange.com/posts/36097/revisions If it was real data you should ask a moderator to redact this data. Commented Jul 13, 2020 at 12:02

2 Answers 2


Check your individual dedupe rule, change the unsupervised one to first name and last name with weight 10 each and total 20.

  • Thanks a million that did the trick. Imported the records with no issue. Thanks a million Commented Jul 11, 2020 at 16:16
  • so can you mark this as answered so that it will help others? Commented Jul 11, 2020 at 16:25

Welcome to SE! I'm guessing you're fairly new to Civi and the comments so far, although accurate, may seem a bit cryptic. I'll expand a bit ...

The end result should be 15 contacts: 10 children, 5 parents and 10 parent/child relationships.

You said '... import the 10 children records first. I then did another import for the 5 parent record'. As per Pete's comment, you don't need to do 2 imports. Civi will import both the child and parent records at the same time using the 'child of' mapping shown in your screenshot.

External identifiers have to be unique across all records (not just those in your import). Your first import created child records with ext id's 1-10 and then the second one (first attempt) tried to create additional child records with ext id's 1-10 and failed because of the uniqueness requirement. Switching to 'Update' gets around that problem, but you can avoid it entirely by doing a single import.

You don't need external identifiers at all for this import and unless you need them for other purposes, I'd skip them entirely. Once you get this import done, if you try repeating the process for a different set of data but reusing ext id 1-10 you'll hit problems. The documentation includes an example for importing two parents, and that does need an ext id. (Rereading that, it would benefit from a simple example of importing relational data as well as the more complex one.)

For the parents, Civi will attempt to match those details to an existing contact. If it succeeds it will use that contact, otherwise it will create a new one. Civi determines what is a match using Dedupe Rules. You can find those at Contacts > Find and Merge Contacts. You can read about those here. The rule used for deciding if the parent details match is the 'Unsupervised rule', so you need to create a rule based on the data in your import for parents (ie some combination of first name, last name and phone). As Pradeep suggests, you can create a rule matching on first/last name and set that as the unsupervised rule.

If you do that and run the import you should find it creates 15 contacts with the right relationships. Confusingly, the import dialog lets you select a dedupe rule but this seems to be used only for the main contacts of the import (children), not the related contacts (parents) - hence the need to change the overall unsupervised rule.

Once you have done the import, go back and change your unsupervised rule to something narrower. In general, first/last name is not enough for uniqueness.

Alternatively, if you already have the data imported with duplicate parent records but don't want to reimport, you can run a manual dedupe using the 'First/Last' rule. See the link above for more info.

  • Thanks for this detailed write-up. With Pradeep and your help, I can now import with confidence. In fact, I read through the documentation you referenced. What it does not indicate is the selections for Step 1 with regard to the option for For Duplicate Contacts and which Dedupe Rule to use. I have also imported the School for the children using Update for For Duplicate Contacts and Name, Surname as unsupervised for the Dedupe Rule. Thanks a million. Thanks for the heads-up with regards to using narrower rules and the "First/Last" rule. Commented Jul 11, 2020 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.