Answers.Body: <p>Check your individual dedupe rule, change the unsupervised one to first name and last name with weight 10 each and total 20.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-11T16:16:25.037Z
Answers.Text: Thanks a million that did the trick. Imported the records with no issue. Thanks a million
Answers.UserDisplayName: pietpompies
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-11T16:25:50.173Z
Answers.Text: so can you mark this as answered so that it will help others?
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-09T16:15:34.080Z
Answers.LastActivityDate: 2020-07-09T16:15:34.080Z
Answers.UserDisplayName: Pradeep Nayak
Answers.Body: <p>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 ...</p>
  <p>The end result should be 15 contacts: 10 children, 5 parents and 10 parent/child relationships.</p>
  <p>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.</p>
  <p>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.</p>
  <p>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 <a href="https://docs.civicrm.org/user/en/latest/common-workflows/importing-data-into-civicrm/#importing-relational-data" rel="nofollow noreferrer">documentation</a> 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.)</p>
  <p>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 <code>Contacts &gt; Find and Merge Contacts</code>.  You can read about those <a href="https://docs.civicrm.org/user/en/latest/common-workflows/deduping-and-merging/" rel="nofollow noreferrer">here</a>.  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.</p>
  <p>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.</p>
  <p>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.</p>
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-11T16:37:06.823Z
Answers.Text: 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.
Answers.UserDisplayName: pietpompies
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-10T10:29:34.030Z
Answers.LastActivityDate: 2020-07-10T10:29:34.030Z
Answers.UserDisplayName: Aidan
Body: <p>I know this should be straight forward, but somehow I seem to struggle.</p>
  <p>Importing a child-parent relationship.</p>
  <p>I have 10 children records (External ID, Child Name, Child Surname) and 5 parent records (Parent Name, Parent Surname, Parent Mobile Number, Subtype).</p>
  <p>I used <a href="https://dmaster.demo.civicrm.org" rel="nofollow noreferrer">https://dmaster.demo.civicrm.org</a> to import the 10 children records first. I then did another import for the 5 parent record:</p>
  <p>I got an error message: External ID already exist in the database</p>
  <p>So, 0 records were imported.</p>
  <p>So, I tried again. This time I selected Update for For Duplicate Contacts</p>
  <p>According to the message, 20 records were created or updated. Thus, I ended up with 20 records.</p>
  <p>I thought that there should be 15 records. For example, if parent A has two children (Child 1 &amp; 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.</p>
  <p>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:</p>
  <p>When I selected Fill for For Duplicated Contacts, 20 records were created or updated.</p>
  <p>Any guidance will be provided or should it be 20 records.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-09T19:55:45.123Z
Comments.Text: also note you should be able to create the children and the parents in the same import
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-10T10:31:17.760Z
Comments.Text: Hopefully this is test data - no real contact data should be posted here.
Comments.UserDisplayName: Aidan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-11T16:19:17.043Z
Comments.Text: @petednz-fuzion, It appears to be the case as explained
Comments.UserDisplayName: pietpompies
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-11T16:19:24.057Z
Comments.Text: @aidan, I have removed the information. Even though I mixed it up, some information was recognisable. Thanks.
Comments.UserDisplayName: pietpompies
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-13T12:02:44.060Z
Comments.Text: @pietpompies just so you are aware the original question is still available in the revision history https://civicrm.stackexchange.com/posts/36097/revisions If it was real data you should ask a moderator to redact this data.
Comments.UserDisplayName: William Mortada
Tags: <import><relationships>
Title: Importing Relationship Data
ThreadText: # Importing Relationship Data
  
  (Asked by: username_0 on 2020-07-09)
  
  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.
  
  **Tags:** import, relationships
  
  > **Comments:**
  > **username_1**: also note you should be able to create the children and the parents in the same import  
  > **username_2**: Hopefully this is test data - no real contact data should be posted here.  
  > **username_0**: @petednz-fuzion, It appears to be the case as explained  
  > **username_0**: @aidan, I have removed the information. Even though I mixed it up, some information was recognisable. Thanks.  
  > **username_3**: @username_0 just so you are aware the original question is still available in the revision history https://civicrm.stackexchange.com/posts/36097/revisions If it was real data you should ask a moderator to redact this data.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2020-07-09. Score: 1 | Accepted answer
  
  Check your individual dedupe rule, change the unsupervised one to first name and last name with weight 10 each and total 20.
  
  > **Comments:**
  > **username_0**: Thanks a million that did the trick. Imported the records with no issue. Thanks a million  
  > **username_4**: so can you mark this as answered so that it will help others?  
  
  ---
  
  ### Answer by username_2 on 2020-07-10. Score: 1
  
  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](https://docs.civicrm.org/user/en/latest/common-workflows/importing-data-into-civicrm/#importing-relational-data) 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](https://docs.civicrm.org/user/en/latest/common-workflows/deduping-and-merging/). 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.
  
  > **Comments:**
  > **username_0**: 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.  
  
  ---
  
  