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

# Star schema

In Peliqan you can model your data as you like, for example by using the [Star schema data model](https://en.wikipedia.org/wiki/Star_schema).

Below is a simple example where we build one fact table and a few dimension tables, based on tables from a CRM called “Teamleader”.

The below queries can be created as **Views** in the data warehouse, to make them visible by your BI tool. See Query Settings > Create as view.

Or you can “**Materialize**” these queries into a physical table in the data warehouse, using Query Settings > Replicate. More info: [Materialize & Replicate](/materialize)

<img src="https://mintcdn.com/peliqan-9d7f0393/YRHnL7-4qstObFqf/images/Metadata,%20Data%20models%20&%20Semantic%20models/Building%20a%20Star%20schema/Screenshot_2025-12-05_at_17.17.15.png?fit=max&auto=format&n=YRHnL7-4qstObFqf&q=85&s=811c82d80cd85cb72a4f20b8a4d7ee56" alt="Star schema diagram: fact table fct_deals linked to dimension tables dim_customer and dim_status" width="2124" height="1164" data-path="images/Metadata, Data models & Semantic models/Building a Star schema/Screenshot_2025-12-05_at_17.17.15.png" />

### Dimension table “customer”: dim\_customer

The source table is the table “companies”, created by the ELT pipeline:

```sql theme={null}
SELECT
  id AS customer_id,
  name,
  address
FROM teamleader.companies
```

### Dimension table “status”: dim\_status

The source is column “status” from the table “deals”, created by the ELT pipeline:

```sql theme={null}
SELECT
  ROW_NUMBER() OVER () AS status_id,  -- Create an ID for each status
  status
FROM (
  SELECT DISTINCT
    status
  FROM teamleader.deals
  ORDER BY
    status
) AS t
```

### Fact table “deals”: fct\_deals

The fact table is created based on the source table “deals” from the ELT pipeline, combined with the id’s from the dimension tables, which are added as FK:

```sql theme={null}
SELECT
  d.id AS deal_id,
  d.title AS deal_title,
  d.estimated_value_amount,
  d.weighted_value_amount,
  d.company_id AS customer_id,       -- FK to dimension Customer
  s.status_id                        -- FK to dimension Status
FROM teamleader.deals AS d
LEFT JOIN dim_status AS s
  ON d.status = s.status
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.