JSON-ON-RELATIONS: A Framework Converts JSON to SQL

Kai Zhang
Kai Zhang
Dec 24, 2018 · 5 min read

First Glance

Define Your Entity

Entity: person
Role: employee
Relation: r_employee
Relationship: marriage

Browse and Maintain Entity Instances

An instance of person entity
Search & List person instances

Compose Your Message

A person instance displayed in JSON format
POST http://localhost:3001/api/entity
Accept: */*
Cache-Control: no-cache
Content-Type: application/json

{ "ENTITY_ID": "person",
"person": {"HEIGHT": "180", "GENDER": "male", "HOBBY":"Reading, Movie, Coding"},
"r_user": {"USER_ID": "DH999", "USER_NAME":"John", "DISPLAY_NAME": "John Wu"},
"r_email": [{"EMAIL": "dh999@hotmail.com", "TYPE": "private", "PRIMARY":1}],
"r_employee": {"USER_ID": "DH999", "COMPANY_ID":"Darkhouse", "DEPARTMENT_ID":"Development","TITLE":"Developer"},
"relationships":[
{ "RELATIONSHIP_ID": "rs_user_role",
"values":[
{ "SYNCED":0,
"PARTNER_INSTANCES":[
{"ENTITY_ID":"system_role", "ROLE_ID":"system_role", "INSTANCE_GUID":"5F50DE92743683E1ED7F964E5B9F6167"}]}
]
}]
}
PUT http://localhost:3001/api/entity
Accept: */*
Cache-Control: no-cache
Content-Type: application/json

{ "ENTITY_ID": "person",
"INSTANCE_GUID": "2FBE7490E10F11E8A90957FA46F2CECA",
"r_employee": {"action": "update", "USER_ID": "DH001", "TITLE": "Architect"},
}
PUT http://localhost:3001/api/entity
Accept: */*
Cache-Control: no-cache
Content-Type: application/json

{ "ENTITY_ID": "person",
"INSTANCE_GUID": "2FBE7490E10F11E8A90957FA46F2CECA",
"r_address": [
{"action": "add", "COUNTRY": "China", "CITY":"Shanghai", "POSTCODE": "777777",
"ADDRESS_VALUE":"Building #909, YYYY Road #101",
"TYPE": "Office", "PRIMARY":0}
]
}

Try It

Concept Behind

Entity & Relationship Model

Epilogue

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade