Skip to content

Many-to-many relationship with foreign keys and arrays possible? #862

Description

@simnh

Hey,

I wondered if there is a way to represent a many to many (many to 1, 1 to many) relation within a data package using foreign-keys. I do not what to add another table representing this relation as it would be done in a relation database)

I have a datapackage.json example like the one below, where I would like to have a array of strings in one field and reference to another file the this foreign-key array.

{
  "profile": "tabular-data-package",
  "name": "test_data_set",
  "resources": [
    {
      "name": "hubs",
      "path": "elements/hubs.csv",
      "profile": "tabular-data-resource",
      "schema": {
        "fields": [
          {
            "name": "name",
            "type": "string"
          }
        ]
      }
    },
    {
      "name": "sinks",
      "profile": "tabular-data-resource",
      "path": "elements/sinks.csv",
      "schema": {
        "fields": [
          {
            "name": "name",
            "type": "string"
          }
          {
            "name": "predecessors_fkey",
            "type": "array"
          }
        ],
        "foreignKeys": [
          {
            "fields": "predecessors_fkey",
            "reference": {
              "resource": "hubs",
              "fields": "name"
            }
          }
        ]
      }
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions