Replies: 2 comments 1 reply
-
The main thing that's missing from JSON Schema to support something like this is that there's no concept of a database (using the term loosely) of JSON instances that defines what instances exist and what schemas they conform to. I don't think that belongs as a part of JSON Schema, but rather as a product that uses JSON Schema. I don't think we want to be in the business of specifying a database system. Once you have a database system of some kind, you could then create a custom dialect of JSON Schema that includes a keyword that can declare something as a foreign key and validate based on that relationship. |
Beta Was this translation helpful? Give feedback.
-
I agree that the db of what instances exist and what schemas they conform to is a separate tool, as would be enforcing the foreign key relationships. What I'm thinking of here is purely on the schema definition side. We already have a way for one schema to say "the definition of this property is an entire other schema", e.g. Consider if we had a way to say "the definition of this property is identical to a specific field in another schema", which might look something like Once that relationship between schema contents was possible, then marking such a relationship as to be enforced based on the data in the files would be a lot less of a stretch. Maybe if I'm going to bring this forward as a proposal, that first step of just having property refs would be a better target? It's simpler and more general purpose. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have two schema, call them A and B, that each describe an object with an
id
key, and A has aB_id
key. I want to indicate thatA.B_id
refers toB.id
, such that some tool might be able to parse the relevant json files and check/enforce that everyA.B_id
matches someB.id
. This is analogous to a foreign key relationship in a relational database.Is there a way to do this in JSON Schema? Are there any existing proposals to add this sort of functionality? Are there third party tools or other standards that could be used to accomplish this?
Beta Was this translation helpful? Give feedback.
All reactions