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

# Create an Entity Relation Table

> Learn how to create an entity relation table to connect anonymous users to authenticated users.

[Entity relation tables](../metrics/entity-relation-tables) connect anonymous users to authenticated users for experimentation.

## Create the Entity Relation Table

<Steps>
  <Step title="Open the entity that should own the relation">
    Open the entity that you randomize on (for example, Visitor).
  </Step>

  <Step title="Go to the Entity relation tables section">
    In the **Entity relation tables** section, click **Create**.
  </Step>

  <Step title="Input a SQL query">
    Input a SQL query that outputs two columns that specifies the mapping between the entities.
  </Step>

  <Step title="Select the columns and target entity">
    Select the columns and the target entity (for example, User).
  </Step>

  <Step title="Click Create" />
</Steps>

<Note>
  Confidence doesn't clean the data coming from this table, so it's important that it's of high quality
  to ensure trustable experiment results. Any required data cleaning can either be done before the data ends up in the
  relation table, or inline in the table definition since it can be any SQL query.

  Below is a short description of possible error cases and how those would affect the results, using the **Visitor** to **User** case as an example:

  * No mapping exists for a visitor ID: For metrics with padding enabled, the user is included in the calculation of the metrics for the experiment, but get 0 as the metric value. Otherwise, the user is excluded.
  * Multiple visitor ID's map to the same user: The user would be included once, with first exposure set to the earliest assignment for the visitor ID.
  * One visitor ID maps to multiple users: All users mapped to the visitor ID would be considered exposed to the experiment.
</Note>

## Create the Experiment

With the entity relation table in place, you can now create the experiment.

<Steps>
  <Step title="Create an experiment">
    Create an experiment and choose the entity that owns the relation as the entity to randomize on.
  </Step>

  <Step title="Select metrics from both entities">
    When selecting metrics you should now see metrics from both entities in the metric picker that you can then configure as in any other experiment.
  </Step>
</Steps>

## Related Resources

<CardGroup cols={2}>
  <Card title="Entity Relation Tables Reference" href="/docs/metrics/entity-relation-tables">
    Deep dive into entity relation configuration
  </Card>

  <Card title="Entities Reference" href="/docs/metrics/entities">
    Learn about entity types and configuration
  </Card>

  <Card title="Unauthenticated Users" href="/docs/experiments/unauthenticated-users">
    Handle anonymous user experiments
  </Card>

  <Card title="Launch an A/B Test" href="/docs/quickstarts/launch-abtest">
    Run experiments with related entities
  </Card>
</CardGroup>
