DBJSON: SELECT * FROM persons AS JSON

Back to the main theme

Traveling further ‘down’ from the top-level DBJSON object, is the top-level syntax of DBJSONtm messages (described in JSON notation). These are called top level types, and their names are reserved DBJSON names.


{ dbjson : {
guid   : "..." , // GUID of the message
sender : "..." , // GUID of the sender
selector   : {},
descriptor : {},
declarator : {},
updater    : {},
terminator : {},
transactor : {},
connector : {},
rezult : {}
} }

‘guid’ and ‘sender’ properties are solving the issue of distributed systems typeless messaging. I can refer you to THIS URL , which might be used just as an “inspiration”.

The rest,  conceptually maps to the SQL protocol, used to communicate with the DB.  Any of these eight top level DBJSON types can appear once in one DBJSON message, that is sent to the data service, or received from it. Top level types can appear only on the top level. Further down I will define structure and rules for each of these fundamental, aka “top level”, types.

dbjson.rezult

DBJSON message that has arrived from the data source. It is again a set of JSON objects representing data source rezult set. Example of an dbjson.rezult would be :

 

The above simply maps SQL result to the dbjson.rezult.  It does not contain any elaborate ‘things’ like table and column descriptors etc. Thus it is not ‘self describing’. Unless we add to the dbjson message top level types which make it self describing :

To make above message even more self describing we can add a connector object which will reveal the name of the data source, etc.

DBJSON Entities

There is a number of DBJSON entities which are directly mapped from the SQL world, as DB entities. Following table is mapping of SQL DDL entities and concepts.

SQL DDL entity DBJSON entity Comment
server { server : {name : "server name"}} 'name' is the only mandatory property.
database { database : {name : "db name"}} 'name' is the only mandatory property.
table { table : {name : "table name",view : true, /* this is view */

‘name’ is the only mandatory property.

 

‘name’ and ‘type’ are the only mandatory properties.

 

DBJSON data types

There is a number of DBJSON data type presentations which are directly mapped from the SQL world of data types. Here obviously we might meet specific types as defined by some RDBMS-es but not the others.

DB data type DBJSON data type Comment
varchar “string” JavaScript string
int 123 JavaScript integer
float 123.456 JavaScript float
binary ” … “ 64 bit encoded string

 

Next page please.

6 thoughts on “DBJSON: SELECT * FROM persons AS JSON”

Comments are closed.