N:N Relationships

33 views
Skip to first unread message

Marcelo Iturbe

unread,
Feb 7, 2018, 4:25:21 AM2/7/18
to JSON Schema
Hello,
I understand that I can specify relations as described in a post from a few years back: https://goo.gl/UsQxqF

{
  
"type": "object",
  
"properties": {
    
"id": { "type": "string" },
    
"foo": { "$ref": "http://example.com/schema/foo" }
    
"bar": { "$ref": "http://example.com/schema/bar" }
  
}
}
{
 
"id": "asdf1234",
 
"foo": { "$ref": "http://example.com/foo/1" },
 
"bar": { "$ref": "http://example.com/bar/1" },
}


This works well if it is a N:1 or 1:1 relation, but my question is in regards to N:N relationships. For example a contact could be associated to multiple companies and a company in turn could have multiple contacts.

How could that be represented? would I have to create an array of objects in the contacts schema and vice versa?
Is there any way to specify 1:1, 1:N, N:1 and N:N? 

Did I miss something?

Ben Hutton (@Relequestual)

unread,
Feb 8, 2018, 4:37:31 AM2/8/18
to JSON Schema
Hi Marcelo,

The example you picked up on in a previous post is to do with Hyper Schema, and not validation.
It's pretty impossible to work out what you're asking, as I'm not even sure the example schema you've pasted is valid.
Prehapse show us some data and the real schema you have so far?

Cheers
Ben
Reply all
Reply to author
Forward
0 new messages