# Bookings revenue data plan
- create new cube with data for only 1 org - can test there and can rebuild fast
- execute mostly partial build - full build is needed only to refech the data from Mongo and is slower
- the end goal of the story is to extend the FactBookings table with 3 more properties - price, coins, credits
- price - the sum of all fees for booking
- coins - the sum of all coins used for the booking
- credits - the sum of all hourly credits for the booking
- before getting new collection from Mongo check if it already exists in Sisense
- you can use custom middle tables
- the general rule in Sisense is less custom tables are better but my approach is first to make it work and then think how to optimize
- if you want to get back to previous working state export the cube before you start working
- you can then import the old cube and restore the working state
- recap on how joins works
- when you implement a calculation in the SQL cross check in Mongo if the data is correct
- if you don't see data in any table it can be one of few reasons:
- data is not selected when we fetch the table from mongo
- data is not selected when we create custom table in Sisense
- data is represented as separate table - there are no nested tables in SQL so every mongo nested table shows up like another table
- when joining ineer collections to the main collection they should be joined by the "_id" prop for both collections. Example
- we have bookings table. Every booking has _id prop
- we have a bookings_credits table. Every booking_cretid has _id prop. This is actually the _id of the booking. This is because in Mongo booking_credits are inner collections without their own IDs.
- so the way we JOIN them is: ```bookings.[_id] = bookings_credits.[_id]```
- when we join an inner collection most likely we want the aggregated result from the inner array. Examples:
- bookings credits, fees - we want the sum
- memberships addons, plans addons - we want the sum
- use the Preview feature to check results fast
---
Sisense data modeling tips and tricks article - https://officernd.atlassian.net/wiki/spaces/HOME/pages/1624244228/Data+Modelling+tips+tricks