There are three cubes that I need to create, namely, "Order", "OrderItem" and "Adjustment". Adjustments can belong to Order or OrderItem (not to both at the same time).
Order -> Adjustment is a one-to-many relationship and therefore Order has "hasMany" join with Adjustment.
OrderItem -> Adjustment is also a one-to-many relationship and so OrderItem has "hasMany" join with Adjustment.
Now, how do I model the Adjustment cube? Can it have two joins of the "belongsTo" kind like the following:
cube('Adjustments', {
sql: `SELECT * FROM "orders-parquet-${ENVIRONMENT}".order_adjustments`,
joins: {
Orders: {
relationship: 'belongsTo',
sql: `${Orders}.order_id = ${Adjustments}.order_id`,
},
OrderItems: {
relationship: 'belongsTo',
sql: `${OrderItems}.order_item_id = ${Adjustments}.order_item_id`,
},
},
Is this the proper way to model the cubes? I googled but could not find any example where two "belongsTo" joins were used in one cube.