> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create parent-child relationships

> The indexing technique for maintaining parent-child relationships between records when you migrate data to Algolia's JSON format.

If your source data has parent-child relationships between records and you want to maintain those relationships when you migrate to Algolia's JSON format, this guide outlines the recommended indexing process.

Use parent-child relationships when you want to:

* [Filter](/doc/guides/managing-results/refine-results/filtering) on children
* Update parents without affecting children
* Index a tree-like data structure
* Model a [one-to-many](https://wikipedia.org/wiki/One-to-many_\(data_model\)) relationship.

## Model relationships in your JSON file

To model a parent-child relationship in [the records of your Algolia JSON data](/doc/guides/sending-and-managing-data/prepare-your-data#algolia-records):

* **Create one record per child**,
  and add a unique reference to their parent as a key-value pair (`parentID` in the example)

* **Don't create records for parents**.

### Dataset

```json JSON icon=braces theme={"system"}
[
   {
      "parentID":"ABC",
      "parentName":"Parent",
      "name":"Child One"
   },
   {
      "parentID":"ABC",
      "parentName":"Parent",
      "name":"Child Two"
   }
]
```

## Implementation notes

Since this structure doesn't have parent records, you can only query children.
To retrieve the most relevant child per parent (`parentID` in the preceding example),
use [Algolia's distinct feature](/doc/guides/managing-results/refine-results/grouping).

For more information, see:

* [Index relational data](/doc/guides/sending-and-managing-data/prepare-your-data/how-to/handling-data-relationships)
* [Prepare your data for indexing](/doc/guides/sending-and-managing-data/prepare-your-data/in-depth/prepare-data-in-depth)
* [Filter attributes with rules](/doc/guides/managing-results/rules/rules-overview/in-depth/implementing-rules#only-the-filtering-attributes-in-the-condition-matter)
* [Nested attributes](/doc/guides/sending-and-managing-data/prepare-your-data/how-to/creating-and-using-nested-attributes)
