cubes:
  - name: customers
    sql: "SELECT * FROM customers"
    joins:
      - name: orders
        relationship: one_to_many
        sql: "{customers}.id = {orders.customer_id}"
      - name: returns
        relationship: one_to_many
        sql: "{customers}.id = {returns.customer_id}"
    dimensions:
      - name: id
        type: number
        sql: id
        primary_key: true
      - name: name
        type: string
        sql: name
      - name: city
        type: string
        sql: city
    measures:
      - name: count
        type: count

  - name: orders
    sql: "SELECT * FROM orders"
    dimensions:
      - name: id
        type: number
        sql: id
        primary_key: true
      - name: customer_id
        type: number
        sql: customer_id
      - name: status
        type: string
        sql: status
      - name: created_at
        type: time
        sql: created_at
    measures:
      - name: count
        type: count
      - name: total_amount
        type: sum
        sql: amount

  - name: returns
    sql: "SELECT * FROM returns"
    dimensions:
      - name: id
        type: number
        sql: id
        primary_key: true
      - name: customer_id
        type: number
        sql: customer_id
      - name: reason
        type: string
        sql: reason
      - name: created_at
        type: time
        sql: created_at
    measures:
      - name: count
        type: count
      - name: total_refund
        type: sum
        sql: refund_amount
