[dojo-contributors] dojo.data Schema API

Brian Douglas Skinner skinner at dojotoolkit.org
Tue Aug 21 17:26:01 EDT 2007


Hey Jon,

It'd be great to get help with this!

Although the simple cases seem pretty easy (just need a way to specify a 
list of attributes, and maybe the datatype of each attribute), it seems 
like the more involved cases might quickly get thorny.

Ideally it would be good to come up with a Schema format that works 
reasonably well as a least-common-denominator across a wide range of 
datastores that connect to very different server-side data sources.

It might be pretty easy to come up with a Schema format that works well 
for any RDMBS, and maybe pretty easy to make a format that works okay 
for any XML database server that uses XML Schema, and maybe pretty easy 
to make a format that works okay for RDF servers that use RDF Schema, 
but it seems like it'll be hard come up with some simple lingua-franca 
format designed to work reasonable well for XML, RDF, RDBMS, and 
everything else as well.

:o) Brian


Jon Sykes wrote:
> Brian,
> This looks very interesting, and along similar lines to something I  
> was playing around with a while ago for http://microjson.org/ the  
> idea here was to try to convert and extend some of the microformat  
> work into the JSON world, with the same aim.  That you could end up  
> with having code (server or client) that could identify common  
> 'chunks' of data out of a larger 'chunks' of data because it followed  
> some loose JSON data form structure.
> 
> My idea being that if everyone had for example "people data"  
> structured the same way (jCard) in open API type services, it would  
> make writing data parsers for mashup style applications all that easier.
> 
> I did a bunch of research on creating JSON schema's (damned use the  
> phrase Schema around ex-XML folk who are now JSON converts and they  
> get VERY angry.)  I wanted to be able to have a way of showing the  
> expected format (not necessarily for validation purposes - although  
> that could open up other interesting doors of possibility).
> 
> I'd love to see where this goes, and if I can do anything to help  
> don't hesitate to ask.
> 
> Jon
> 
> 
> On Aug 21, 2007, at 3:49 PM, Brian Douglas Skinner wrote:
> 
>> In some recent dojo.data IRC meetings, Jared and Alex and I started
>> talking about what we might want the Schema API to look like.
>>
>> The main purpose of the Schema API is just to provide metadata  
>> about all
>> the attributes that different kinds of items can have.  For  
>> example, in
>> a bookstore database, you might have different kinds of items for
>> representing Customers and Books.  The Customer items would have
>> attributes like Name, Phone Number, and Billing Address.  The Book  
>> items
>> would have attributes like Title, Author, and ISBN.
>>
>> We'd like to get feedback from more people about what the Schema API
>> should look like.  We haven't yet talked about many of the details,  
>> but
>> here's a rough approximation of the sort of approach we've been  
>> talking
>> about...
>>
>> The Schema API might have just two methods:
>>
>>    store.getSchema();
>>    store.getKindOfItem(item);  // or maybe just getKind(item)
>>
>> Calling store.getSchema() would return a JSON-like object structure  
>> with
>> all the schema info for the entire datastore.
>>
>> For example, say you have a datastore that's connected to a relational
>> database, and the database has two tables that look like these:
>>
>>    TABLE Country:
>>              ABBR  NAME
>>              ----  -------
>>              UKR   Ukraine
>>              USA   United States
>>
>>    TABLE State:
>>              NAME  CODE  COUNTRY  POPULATION
>>              ----  ----  -------  ----------
>>              Utah  UT    USA       2,233,169
>>              Ohio  OH    USA      11,353,140
>>
>> If you call getSchema() like this:
>>
>>     var schema = store.getSchema();
>>
>> Then the schema object you get back would look something like this:
>>
>>      schema == {
>>          kinds: {
>>              Country: {
>>                  attributes: {
>>                      ABBR: {type: 'String'},
>>                      NAME: {type: 'String'}
>>                  }
>>              },
>>              State: {
>>                  attributes: {
>>                      NAME: {type: 'String'},
>>                      CODE: {type: 'String'},
>>                      COUNTRY: {kind: 'Country'},
>>                      POPULATION: {type: 'Number'}
>>                  }
>>              }
>>          }
>>      }
>>
>> Or it could perhaps have additional metadata:
>>
>>      schema == {
>>          kinds: {
>>              Country: {
>>                  label: ['NAME'],
>>                  identifier: ['ABBR'],
>>                  attributes: {
>>                      ABBR: {
>>                          label: 'Abbreviation',
>>                          summary: 'An ISO 3166-1 country code',
>>                          type: 'String',
>>                          sourceType: 'char(3)'
>>                      },
>>                      NAME: {
>>                          label: 'Country Name',
>>                          type: 'String',
>>                          sourceType: 'varchar(255)'
>>                      }
>>                  }
>>              },
>>              State: {
>>                  label: ['NAME'],
>>                  identifier: ['CODE'],
>>                  attributes: {
>>                      NAME: {
>>                          label: 'State Name',
>>                          type: 'String',
>>                          sourceType: 'varchar(255)'
>>                      },
>>                      CODE: {
>>                          label: 'Postal Code',
>>                          type:'String',
>>                          sourceType: 'char(2)'
>>                      },
>>                      COUNTRY: {
>>                          summary: 'Country this State is part of',
>>                          kind: 'Country'
>>                      },
>>                      POPULATION: {
>>                          label: 'Population',
>>                          type: 'Number',
>>                          sourceType: 'int'
>>                      }
>>                  }
>>              }
>>          }
>>      }
>>
>>
>> _______________________________________________
>> dojo-contributors mailing list
>> dojo-contributors at dojotoolkit.org
>> http://dojotoolkit.org/mailman/listinfo/dojo-contributors
> 
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-contributors




More information about the dojo-contributors mailing list