# RubikBench ## Database Description RubikBench is a database containing the **financial** data of *APEX*, an (imaginary) international **automobile** manufacturing and sales company. As a financial database, it is designed to support various analytical queries related to the company's operations, sales, and financial performance. This (imaginary) company operates mainly in China, the United States, and Europe. Therefore, the database is bilingual, with both English and Chinese values, and uses three currencies: CNY, USD, and EUR (the values are interchangeable rather than cumulative; EUR and USD figures are derived from CNY based on the world monthly exchange rates). There are **6 key dimensions**: *Period* (time, monthly), *Product*, *Region*, *Customer*, *Dealer*, and *Report Item* (revenues and expenses). Extra dimensions include *Contract*, *Project*, *Currency*, and *Caliber*. The minimal granularity of the data is a single **project** **payment**. Each **project** occurs between APEX and a **customer** in a specific **region**, with an optional **dealer**, over a specified **period** of time. **Payments** for a project can be distributed over multiple months within that time period. Each project may contain multiple **products**. Each **contract** may contain multiple projects. RubikBench contains **20 tables** in **4 major categories**. Each is an aggregated view over the fact table, which is not exposed directly: - The `INCOME` tables, which contain data aggregated over project and dealer, and only include revenues. The INCOME tables are the smallest tables in RubikBench, aiming for quick analytical queries. - The `BUDGET_AND_FORECAST` tables, which contain data aggregated over project, customer, and dealer. These tables contain only forecast/budget/target values, not actual revenues or expenses. Notice that the semantics of these values could be counter-intuitive: While the target value is the target for monthly revenues and expenses in `YYYYMM`, as one would expect; the forecast value of `YYYYMM` is the forecast of `YYYY12` (yearly) based on the information available at the end of `YYYYMM`; the budget of `YYYYMM` is a constant value indicating the yearly budget duplicated for each month in the year. - The `PROFIT_AND_LOSS` table, which contains data aggregated only over the project. It contains the most comprehensive dimensions and measures, including both revenues and expenses. It is the largest table in RubikBench, aiming to support detailed financial analysis. - The `SALES_LEDGER` table, which contains the lowest granularity data, i.e., payment-level data. It is designed to support detailed audit and traceability of revenues. However, it is limited to sales revenues and expenses only. The products of APEX are divided into **3 major divisions**: *Automobiles*, *Accessories*, and *Services*. - *Automobiles* are produced by enterprise brand groups, which are **6 sub-brands** under APEX. Each brand group has its own `INCOME` and `BUDGET_AND_FORECAST` tables. - *Accessories* and *Services* each have their own `INCOME` and `BUDGET_AND_FORECAST` tables. Accessories only have equipment revenues and costs, while services only have service revenues and costs. The default Caliber is code *A*, which clearly separates equipment and service report items, reflecting the real financial statistics. However, to facilitate the cooperation between different divisions, there is also Caliber *B*, which moves 5% of service revenue to equipment revenue. Notice that due to historical reasons as well as query speed expectations, currencies and calibers are organized differently across different tables. For example, for the INCOME and PROFIT_AND_LOSS tables, different currencies and calibers are stored in different columns as column name suffixes (e.g., `_cny_a`, `_usd_a`, `_eur_b`, etc.); while for the SALES_LEDGER and BUDGET_AND_FORECAST tables, `caliber` and `currency` are separate columns that MUST be filtered on in the query predicates to avoid duplicated results. Financial amounts present both `ptd` (monthly) values and `ytd` (year-to-date) values. For example, `ptd` of `YYYYMM` means the amount for that month, while `ytd` of `YYYYMM` means the cumulative amount from `YYYY01` to `YYYYMM` (inclusive). Furthermore, `_py` columns contain previous year data, which means that, for example, ytd py columns with `period='YYYYMM'` contain cumulative amounts from `YYYY-1 01` to `YYYY-1 MM`, etc.