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

# Build marts models

> Use DinoAI to build intermediate and marts models that join multiple tables with the right relationships, CTEs, and business logic.

DinoAI can analyze your existing models, understand how they relate, and create well-structured intermediate and marts models with the right joins. In this guide you generate a marts model that combines several base models.

<Note>
  **Prerequisites**

  * DinoAI copilot access in your Paradime workspace.
  * A dbt™ project with base or staging models to combine.

  Estimated time: 5 minutes.
</Note>

## Steps

<Steps>
  <Step title="Add the base models as context">
    In DinoAI, click the "@" symbol and select the relevant base models so DinoAI knows exactly which tables to include and how they relate.

    <Info>
      Adding the relevant base models as context is the most reliable way to get correct join conditions.
    </Info>
  </Step>

  <Step title="Enter your prompt">
    Describe the model you want to build. For example:

    > I want to create an intermediate model that lets me understand data across races as well as constructor and driver standings for the season.

    DinoAI analyzes the structure of the models you provide, identifies relationships between tables (for example, foreign keys), and creates a new model with well-structured CTEs and join conditions. If configured, it applies your [.dinorules](/guides/dinoai-copilot-use-cases/using-your-project-as-context-to-set-up-.dinorules) preferences.
  </Step>

  <Step title="Review the generated model">
    Review the SQL before accepting it. The output uses CTEs for each source and applies the join conditions DinoAI inferred from the relationships.

    <Accordion title="Intermediate model example">
      ```sql theme={"system"}
      {{ config(materialized='table') }}

      WITH races AS (
          SELECT * FROM {{ ref('stg_f1_races') }}
      ),

      circuits AS (
          SELECT * FROM {{ ref('stg_f1_circuits') }}
      ),

      results AS (
          SELECT * FROM {{ ref('stg_f1_results') }}
      ),

      constructors AS (
          SELECT * FROM {{ ref('stg_f1_constructors') }}
      ),

      driver_standings AS (
          SELECT * FROM {{ ref('stg_f1_driver_standings') }}
      ),

      race_details AS (
          SELECT
              r.race_id, r.year, r.round, r.name AS race_name,
              c.circuit_name, c.location, c.country, r.date AS race_date
          FROM races r
          LEFT JOIN circuits c ON r.circuit_id = c.circuit_id
      ),

      race_results AS (
          SELECT
              res.race_id, res.driver_id, res.constructor_id,
              con.constructor_name, con.nationality AS constructor_nationality,
              res.grid, res.position, res.points
          FROM results res
          LEFT JOIN constructors con ON res.constructor_id = con.constructor_id
      )

      SELECT
          rd.race_id, rd.year, rd.round, rd.race_name, rd.circuit_name, rd.country, rd.race_date,
          rr.constructor_id, rr.constructor_name, rr.constructor_nationality,
          rr.driver_id, rr.grid, rr.position, rr.points,
          ds.position AS driver_standing_position, ds.points AS driver_total_points
      FROM race_details rd
      JOIN race_results rr ON rd.race_id = rr.race_id
      LEFT JOIN driver_standings ds ON rr.driver_id = ds.driver_id AND rd.race_id = ds.race_id
      ORDER BY rd.year, rd.round, rr.position
      ```
    </Accordion>
  </Step>

  <Step title="Accept and test the model">
    Accept the changes to create the file, then build the model to confirm the joins and business logic produce the expected results.
  </Step>
</Steps>

<Check>
  The model builds without errors and combines the source tables with the relationships you expected. If a join returns duplicate or missing rows, verify the join keys in the generated CTEs against your base models.
</Check>

## Next steps

<CardGroup cols={2}>
  <Card title="Generate documentation" href="/guides/dinoai-copilot-use-cases/generating-documentation" icon="book">
    Add model and column descriptions with tests.
  </Card>

  <Card title="Configure data pipelines" href="/guides/dinoai-copilot-use-cases/configuring-data-pipelines" icon="workflow">
    Set materializations, schemas, and tags for your models.
  </Card>

  <Card title="DinoAI use cases" href="/guides/dinoai-copilot-use-cases/index" icon="sparkles">
    Explore more ways to work with DinoAI.
  </Card>

  <Card title="Copilot reference" href="/products/dino-ai/copilot/index" icon="bot">
    How context and Agent Mode work.
  </Card>
</CardGroup>


## Related topics

- [Generate dbt™ models](/guides/dinoai-copilot-use-cases/generating-dbt-tm-models.md)
- [DinoAI copilot use cases](/guides/dinoai-copilot-use-cases/index.md)
- [Configure data pipelines](/guides/dinoai-copilot-use-cases/configuring-data-pipelines.md)
- [Generate documentation](/guides/dinoai-copilot-use-cases/generating-documentation.md)
- [What is dbt™?](/guides/foundations/what-is-dbt.md)
