Open suntong opened 7 years ago
Sorry, I think I was wrong, again, -- I was too eager to share my findings.
Having taken a closer look at JSON Schema, I realized it is for more general purpose, not 100% fit for defining table Schema (but not too far either).
So you may need to borrow the notations from doctrine as well -- http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html
Check out the YAML notation, for e.g., Many-To-One, Unidirectional, it's
User:
type: entity
manyToOne:
address:
targetEntity: Address
joinColumn:
name: address_id
referencedColumnName: id
HTH
I know this project is still under PoC, so here is my 2c on the syntax.
Your current table definition syntax is in JSON form, and it might not have been able to cover every ERD cases possible. This will cause problem for it to be widely adapted, especially if there is a well defined table Schema definition already exist, and backed by big organizations like Red Hat. And the problem is, such thing does exist:
JSON Schema http://json-schema.org/
The Go code is at, https://github.com/xeipuuv/gojsonschema By Suraj Deshmukh from Red Hat
You can find some json-schema examples at http://json-schema.org/examples.html
Also, you can see that it has been already widely adapted, by big names like docker: https://github.com/docker/compose/blob/master/compose/config/config_schema_v3.0.json
So I think you'd better stand on this giant's shoulder instead.
my 2c though.