frictionlessdata / tableschema-sql-py

Generate SQL tables, load and extract data, based on JSON Table Schema descriptors.
MIT License
60 stars 19 forks source link

Adds ForeignKey support per #2 #6

Closed danfowler closed 8 years ago

danfowler commented 9 years ago

When a given column in the JTS has a foreign key defined, it will add a reference to that other table/column (FK’s resource/fields).

pudo commented 9 years ago

Cool. Out of interest: the resource stuff isn't part of the JTS spec, I assume? Is there something like JTS-internal references, i.e. do schemas in JTS have a name which could be used to reference them?

pwalsh commented 9 years ago

@pudo hmmm, that's a tricky one.

I recently added the idea of self-referencing FKs to the spec, but FKs do require that the schema lives in a DataPackage to "know" what is being referenced.

(cf. http://dataprotocols.org/json-table-schema/index.html#foreign-keys)

I'm not sure how what Dan has implemented here works with that.

@danfowler you might want to revisit the spec here, and we can perhaps do an overhaul of how FKs should work in JTS while we are at it.

cc @rgrp

danfowler commented 9 years ago

@pwalsh @pudo this PR doesn't take into account self-referencing foreign keys (which I do need to revisit as I didn't quite understand them from the example in the spec :).

All the mentions of "resources" in the JTS spec assume that the referenced resource lives in a datapackage, no?