Professional Documents
Culture Documents
1
"cubes": [
{
store sales product "name": "sales",
id product_id id "dimensions": ["product", "store"],
"joins": [
code store_id code
{"master":"product_id", "detail":"product.id"},
address amount name {"master":"store_id", "detail":"store.id"}
]
}
fact table has same name as cube, ],
"dimensions": [
dimension tables have same names as { "name": "product", "attributes": ["code", "name"] },
{ "name": "store", "attributes": ["code", "address"] }
dimensions ]
"cubes": [
2 sales
{
...
store ... product "dimensions": ["product", "store", "year"],
...
... year ...
}
amount ],
"dimensions": [
...
dimension represented by only one { "name": "year" }
]
attribute in fact table
Python:
3 dim_store ft_sales dim_product cubes.create_workspace("sql",
id product_id id url=DATABASE_URL,
dimension_prefix="dim_",
code store_id code
fact_prefix="fact_")
address amount name
slicer.ini:
Python:
4 schema: sales_datamart
cubes.create_workspace("sql",
store sales product
url=DATABASE_URL,
id product_id id schema="sales_datamart")
code store_id code
slicer.ini:
address amount name
[workspacee]
all tables are stored in other than default schema="sales_datamart"
database schema
Python:
5 dimensions facts
store sales product cubes.create_workspace("sql",
url=DATABASE_URL,
id product_id id schema="facts",
code store_id code dimension_schema="dimensions",
address amount name )
slicer.ini:
[workspacee]
schema="facts"
all fact tables are stored in one schema, dimensions_schema="dimensions"
6
"cubes": [
{
sales "dimensions": [..., "year"],
store ... product "measures": ["amount"],
"mappings": {
... sales_year ...
"year":"sales_year",
total_amount
"amount":"total_amount"]
}
at dimension is called year, but }
],
column is sales_year; measure is "dimensions": [
...
reported as amount, column is named { "name": "year" }
]
total_amount
"cubes": [
7
dim_suppliers
id dim_organisation {
ft_sales
name id "name": "sales"
supplier_id
address name "dimensions": ["supplier", "client"],
client_id
address "measures": ["amount"],
amount
dim_clients "joins": [
id {
name "master":"supplier_id",
address "detail":"dim_organisation.id",
"alias":"dim_supplier"
clients and suppliers share one table
},
with all organisations and companies {
"master":"client_id",
"detail":"dim_organisation.id",
"alias":"dim_client"
}
]
}
],
"dimensions": [
{
"name": "supplier",
"attributes": ["id", "name", "address"] }
{
"name": "client",
"attributes": ["id", "name", "address"] }
]
"cubes": [
8 {
sales product "dimensions": ["product", ...],
"measures": ["amount"],
product_id id "joins": [
{"master":"product_id", "detail":"product.id"}
... code ]
product
amount name }
],
category_code category "dimensions": [
category {
"name": "product",
"levels": [
{
product dimension has two levels: "name":"category",
"attributes": ["category_code", "category"]
product category and product },
{
"name":"product",
"attributes": ["code", "name"]
}
]
}
]
Cubes modelling patterns
9
"dimensions": [
aggregate or lter {
product
"name": "product",
id "levels": [
{
key code
report "name": "product",
label name "attributes": ["code", "name", "price"]
"key": "code",
price Product Amount "label_attribute": "name"
}
coee 200 ]
tea 250 }
]
milk 50
Use:
Total 500
attribute code to be used for result = browser.aggregate(drilldown=["product"])
"cubes": [
10 product {
sales "name": "sales",
id "label": "Product Sales",
product_id
code "dimensions": ["product", ...]
... }
name
amount ],
price "dimensions": [
{
"name": "product",
"label": "Product",
"attributes": [
Product Unit Price Amount {"name": "code", "label": "Code"},
... ... ...
{"name": "name", "label": "Product"},
{"name": "price", "label": "Unit Price"},
user interface labels for dimensions, }
]
(in dimensions)
11 dim_date year year
id quarter month {
year month day "name":"date",
"levels": [
quarter day
{ "name": "year", "attributes": ["year"] },
month { "name": "quarter", "attributes": ["quarter"] },
month_name { "name": "month", "attributes": ["month", "month_name"] },
year { "name": "week", "attributes": ["week"] },
week
year week { "name": "weekday", "attributes": ["weekday"] },
day
month weekday { "name": "day", "attributes": ["day"] }
weekday ],
"hierarchies": [
{"name": "ymd", "levels":["year", "month", "day"]},
dimension, such as date or geography, {"name": "ym", "levels":["year", "month"]},
{"name": "yqmd", "levels":["year", "quarter", "month", "day"]},
has multiple ways of organizing {"name": "ywd", "levels":["year", "week", "weekday"]}
attributes into a hierarchy ],
"default_hierarchy_name": "ymd"
}
Cubes modelling patterns
12
"dimensions": [
{
product "name": "product",
"label": "Product",
id "attributes": [
{"name": "code", "label": "Code"},
code {
"name": "name",
name_en "label": "Product",
locales: ["en", "fr", "es"]
name_fr }
]
name_es }
]
Notes:
1.only one locale per browser
2.refer to dimension attributes as there was no localisation:
product.name
3.if non-existing locale is requested, then default (rst in the list)
locale is used
Cubes modelling patterns
Use:
! model_sk = model.localize(translation)
Source https://github.com/Stiivi/cubes
Documentation http://packages.python.org/cubes/