openspending / fiscal-data-package

MOVED TO https://github.com/frictionlessdata/specs/issues?q=is%3Aopen+is%3Aissue+label%3A%22Fiscal+Data+Package%22
24 stars 7 forks source link

Make dimension attributes an array of objects, each mapping several logical model fields to source CSV columns #97

Closed danfowler closed 8 years ago

danfowler commented 8 years ago

Adapted with slight modification from this comment by @pwalsh: https://github.com/openspending/fiscal-data-package/issues/48#issuecomment-158681781

Reasoning for this change:

# non-hierarchical dimension with one attribute mapping to several source fields
{
  "name": "function",
  "dimensionType": "classification",
  "attributes": [
    {
      "id": {
        "source": "function1_code"
      },
      "title": {
        "source": "function1_name"
      }
    }
  ]
}

# hierarchical dimension with several attributes mapping to several source fields
{
  "name": "function",
  "dimensionType": "classification",
  "attributes": [
    {
      "id": {
        "source": "function1_code"
      },
      "title": {
        "source": "function1_name"
      }
    },
    {
      "id": {
        "source": "function2_code"
      },
      "title": {
        "source": "function2_name"
      }
    }
  ]
}

If attributes is length == 1, we have a flat dimension object. if attributes is length > 1, we have an indexed hierarchy of dimension objects.

jazzido commented 8 years ago

I've only read the FDP spec superficially, but I sense that a lot of its features resemble an OLAP schema definition language. Maybe you already have, but I suggest taking a look at Mondrian's 4 schema definition language for inspiration.

If it helps, I can share some of the Mondrian schemas that I'm using for budget data in Presupuesto Abierto.