# Creating a dbt™ Model

In this guide, you'll learn how to create your first dbt™ model in the Paradime IDE. By the end of this tutorial, you'll have a fully functional dbt™ model materialized in your data warehouse.

**Estimated completion time:** 10 minutes

{% hint style="info" %}

### Prerequisites

* [Paradime developer or admin permissions](https://docs.paradime.io/app-help/documentation/settings/users/roles-and-permissions)
* [A dbt™ project set up in Paradime](https://docs.paradime.io/app-help/guides/paradime-101/getting-started-with-the-paradime-ide/setting-up-a-dbt-project)
* Basic understanding of SQL and dbt™ concepts
* Basic understanding of Git and version control concepts
  {% endhint %}

### What you'll learn:

* [Create a new file for your model](#id-2.-create-a-new-file)
* [Write a dbt™ model](#id-3.-write-a-dbt-tm-model)
* [Materialize your model](#id-5.-materialize-your-dbt-tm-model)

***

### 1. Create a New Branch

Before creating a model in your dbt™ project, it's essential to work on a new branch to keep your main branch clean and stable. Use Git Lite to create a new branch:

1. **Open Git Lite:** Click the source control icon within the left panel of the IDE.
2. **Create a New Branch:** Using the dropdown, select `+ New Branch` and give it a practical name (e.g., `my_first_dbt_model`).

### 2. Create a New File

{% embed url="<https://youtu.be/dMFjx85PK04>" %}

Create a new .sql file for your dbt™ model:

1. **Open your project file:** Click the folder Icon (📁) in the left panel to view your dbt™ project files.
2. **Create a new file:** Right-click on the folder where you want to add your new file (e.g., `models/sources`) and click `New File`.
3. **Name your file:** Use a descriptive name that reflects the purpose of the model (e.g., `nba_player_info.sql`).

### **3. Write a dbt™ Model**

{% embed url="<https://youtu.be/6Uvt7BCMMyg>" %}

With your new model open in the Code IDE, write SQL that transforms your data, using dbt's jinja syntax to reference sources and models dynamically. For example:

```sql
WITH source AS (
    SELECT 
        person_id AS player_id,
        first_name,
        last_name,
        team_name,
        position,
        height,
        weight
    FROM 
        {{ source('PUBLIC', 'COMMON_PLAYER_INFO') }}
    )
    
    SELECT 
        *
    FROM
        source
```

### 4. Materialize Your dbt™ Model

With your model written and previewed, it's time to materialize it in the data warehouse:

1. **Execute dbt run:** In the terminal at the bottom of your screen, run the command `dbt run`.
2. **Check for errors:** Review any errors or warnings that appear during the build process and resolve them as needed.

{% hint style="info" %}
You can also execute dbt commands from the commands panel. Click the "run model" dropdown and select your desired command for quick access to common dbt operations
{% endhint %}

### 5. Commit and Push

After successfully building your model, commit and push your work using the learnings from the [previous tutorial](https://docs.paradime.io/app-help/guides/paradime-101/setting-up-a-dbt-project#id-4.-version-control).&#x20;

1. **Write your commit message:** Use DinoAI's "Write Commit" feature to automatically generate a detailed commit message tailored to your specific code changes.
2. **Commit and Push:** Save your changes to your local repository, then push them to the remote repository to ensure your work is backed up and accessible.
3. **Open a Pull Request (PR):** Create a PR to allow your team to review and discuss the updates before merging.

***

{% hint style="info" %}

### Related Documentation

* [Using Paradime's integrated terminal (CLI)](https://docs.paradime.io/app-help/documentation/code-ide/terminal)
* [Running dbt™ in Paradime's integrated terminal (CLI)](https://docs.paradime.io/app-help/documentation/code-ide/terminal/running-dbt)
  {% endhint %}

***

### Summary

Congratulations! You've successfully created your first dbt™ model in Paradime, from creating a new branch to committing your changes. Your model is now materialized in your data warehouse and ready for use.

Next, we'll explore [how to use the code IDE for data exploration](https://docs.paradime.io/app-help/guides/paradime-101/getting-started-with-the-paradime-ide/data-exploration-in-the-code-ide).&#x20;
