Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8790617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:42:18+00:00 2026-06-13T22:42:18+00:00

I’m trying to use python’s olap framework cubes on a very simple database, but

  • 0

I’m trying to use python’s olap framework cubes on a very simple database, but I am having some trouble joining tables.

My schema looks like this:

Users table
ID | name

Products table
ID | name | price

Purchases table
ID | user_id | product_id | date

And the cubes model:

{
    'dimensions': [
        {'name': 'user_id'},
        {'name': 'product_id'},
        {'name': 'date'},
    ],
    'cubes': [
        {
            'name': 'purchases',
            'dimensions': ['user_id', 'product_id', 'date'],
            'measures': ['price']
            'mappings': {
                'purchases.user_id': 'users.id',
                'purchases.product_id': 'products.id',
                'purchases.price': 'products.price'
            },
            'joins': [
                {
                    'master': 'purchases.user_id',
                    'detail': 'users.id'
                },
                {
                    'master': 'purchases.product_id',
                    'detail': 'products.id'
                }
            ]
        }
    ]
}

Now I would like to display all the purchases, showing the product’s name, user’s name and purchase date. I can’t seem to find a way to do this. The documentation is a bit scarce.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:42:19+00:00Added an answer on June 13, 2026 at 10:42 pm

    First let’s fix the model a bit. In your schema you have more attributes per dimension: id and name, you might end up having more details in the future. You can add them by specifying attributes as a list: "attriubtes": ["id", "name"]. Note also that the dimension is named as entity product not as a key id_product. The key id_product is just an attribute of the product dimension, as is name or in the future maybe category. Dimension reflects analysts point of view.

    For the time being, we ignore the fact that date should be a special dimension and consider date as single-value key, for example a year, not to make things complicated here.

    "dimensions": [
        {"name": "user", "attributes": ["id", "name"]},
        {"name": "product", "attributes": ["id", "name"]},
        {"name": "date"}
    ],
    

    Because we changed names of the dimensions, we have to change them in the cube’s dimension list:

    "cubes": [
        {
            "name": "purchases",
            "dimensions": ["user", "product", "date"],
            ...
    

    Your schema reflects classic transactional schema, not traditional data warehouse schema. In this case, you have to be explicit, as you were, and mention all necessary mappings. The rule is: if the attribute belongs to a fact table (logical view), then the key is just attribute, such as price, no table specification. If the attribute belongs to a dimension, such as product.id, then the syntax is dimension.attribute. The value of the mappings dictionary is physical table and physical column. See more information about mappings. Mappings for your schema look like:

    "mappings": {
        "price": "products.price",
        "product.id": "products.id",
        "product.name": "products.name",
        "user.id": "users.id",
        "user.name": "users.name"
    }
    

    You would not have to write mappings if your schema was:

    fact purchases
    id | date | user_id | product_id | amount
    
    dimension product
    id | name | price
    
    dimension user
    id | name
    

    In this case you will need only joins, because all dimension attributes are in their respective dimension tables. Note the amount in the fact table, which in your case, as you do not have count of purchased products per purchase, would be the same as price in product.

    Here is the updated model for your model:

    {
        "dimensions": [
            {"name": "user", "attributes": ["id", "name"]},
            {"name": "product", "attributes": ["id", "name"]},
            {"name": "date"}
        ],
        "cubes": [
            {
                "name": "purchases",
                "dimensions": ["user", "product", "date"],
                "measures": ["price"],
                "mappings": {
                    "price": "products.price",
                    "product.id": "products.id",
                    "product.name": "products.name",
                    "user.id": "users.id",
                    "user.name": "users.name"
                },
                "joins": [
                    {
                        "master": "purchases.user_id",
                        "detail": "users.id"
                    },
                    {
                        "master": "purchases.product_id",
                        "detail": "products.id"
                    }
                ]
            }
    
        ]
    }
    

    You can try the model without writing any Python code, just by using the slicer command. For that you will need slicer.ini configuration file:

    [server]
    backend: sql
    port: 5000
    log_level: info
    prettyprint: yes
    
    [workspace]
    url: sqlite:///data.sqlite
    
    [model]
    path: model.json
    

    Change url in [workspace] to point to your database and change path in [model] to point to your model file. Now you can try:

    curl "http://localhost:5000/aggregate"
    

    Also try to drill-down:

    curl "http://localhost:5000/aggregate?drilldown=product"
    

    If you need any further help, just let me know, I’m the Cubes author.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
Let's say I'm outputting a post title and in our database, it's Hello Y’all
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.