cena-dta php conference 2011 slides
TRANSCRIPT
Cena-DTAHTML5 DB
https://github.com/asaokamei/Cena-DTA
@asao_jpWorkSpot.JP
About Cena-DTA
Cena Entity Notation and Augmentation
Source Code at GitHubhttps://github.com/asaokamei/Cena-DTA
GPL v2
Documents at http://www.workspot.jp/cena/ja/index.php
http://www.workspot.jp/cena/index.php
About me
http://www.workspot.jp/
http://twitter.com/asao_jp
Simple
PHP+DB
2002
46
About my past...
University of Idaho, M.E. 1989~1994
Etak, Menlo Park, 1994~2000title: Program Manager
Workspot, inc., Palo Alto, 2000~2001Remote Linux Desktop Server
App development for OmniSky
PalmWireless Modem, One of seven founders!!!
title: VP of Engineering
about Cena-DTA
HTML5 is coming to your web browser
HTML5 = More DataBases!!!Web Storage (x2)Simple session storage & local stroage
Web Sql Database= sqlite = Relational Database!
abandoned... but works in Chrome, Safari, etc.
Web Indexed Databasethis is the future...
Database's Everywhere!
server
Master DatabasePC
local dbsmart phone
local dbnotebook
local db
HTML5 browser brings Database to everywhere.
Master and Local Databases
download all datafrom master local DB.
edit at local DBcreate and modify many data and relations.
upload edited datasynchronize local and master DB.
Synchronizing Relational Data
...but synchronizing
relationship with auto-numbered id
is not easy.
(I think.)
Synchronizing Relational Data #1
create table contact(
contact_id SERIAL,
name text
);
create table connect(
connect_id SERIAL,
contact_id int,
method text
);
contact_idname
9Alan
10George
connect_idcontact_idmethod
1009twitter
10110facebook
10210Tumblr
Synchronizing Relational Data #2
contact_idname
9Alan
10George
11Taro
connect_idcontact_idmethod
10011twitter
10110facebook
10210Tumblr
10311Google+
created: contact_id=11, name=Taro
modified: connect_id=100 contact_id=11
created: connect_id=103 contact_id=11 method=Google+
DB
Synchronizing Relational Data #3
contact_idname
9Alan
10George
11Giro
12Taro
connect_idcontact_idmethod
10011twitter
10110facebook
10210Tumblr
10311mixi
10411Google+
contact_id=11 already occupied!
relation to contact_id=11 is broken!
ID...
Cena-DTA's Objectives
ID
Introducing Cena-DTA #1
Introducing Cena-DTA #2
Cena.connect.mod.100contact_id=Cena.contact.new.11name=TwitterCena.connect.new.103contact_id=Cena.contact.new.11name=Google+Introducing Cena-DTA #3
12
12
Cena.contact.new.11contact_id=11name=Taro
12
Cena Protocol
Cena.model.type.id.action(.column)=value
cena_id: scheme: 'Cena'
model: table, AR, etc.
type: get: from master db,
new: added at local db.
id: primary key
action (state?):set, rel, or del.
or maybe a state...
column: no column for del.
value:string value, or
cena_id for action=rel.
demo
Cena-DTA Demo
create table contact100 ( contact_id SERIAL, name text, gender char(1), type char(1), date date,);
create table contact110 ( connnect_id SERIAL, contact_id int, method text, type char(1));
inside Cena-DTA
Cena-DTA Overview
Server Side: PHPcenaPhprequires PHP5.3 (or above) and MySql (PDO).
Client Side: jQuery's plug-in jqCena: template, utilities
jqCenaSql: interface for WebSqlDatabaserequires WebSqlDatabase and jQuery.
works on Chrome, and probably on Safari...
Cena-DTA Overview
ORM/databaseWebSqlDBcenaPhpjqCenaSqlCena envelope (json)jqCenaHTML5 display/web forms
server side
html5 browsers
html form
ajax
internet
Cena Protocol Formats
Web form styleCena[model][type][id][action][column]=value
Compact styleCena.model.type.id
Cena EnvelopeCena protocol in JSON style
Cena Envelope
Cena protocol in JSON format.example:{
cena_id: Cena.connect.new.103,
type: new,
model: connect,
id: 103,
set: { name: Google+ },
rel: { contact_id: Cena.contact.new.11 }
}
(need better naming...)
Client Side: cenaJq Overview
Cena envelopejqCenaHTML5 display
html5 browsers
HTML5 template
WebSqlDBWebIndexDBjqCenaIdxjqCenaSql
internetajax
Client Side: HTML5 template
male
female ...
Client Side: data and template
var callback100 = function( env_data ) {$().cena( { // initialize cena.env_src: '#cena_env_src', // source envelop id.env_post: '#cena_post', // id to post bound envelope. bind_type: 'replace' // show contents.}).cena( 'add', env_data ).cena( 'bind' ).cena( 'clean' );}
bind_type:- replace : - populate :
Client Side: retrieving data
$().cena( 'restart' );$() .cenaSql().cenaSql( 'find', // set search options #2 { column: opts.find_column,value : opts.find_value,type : opts.find_type}).cenaSql( { // set search options #1model: 'dao_contact100', offset: opts.contact_offset, limit: opts.contact_limit,order: opts.order_column,ascend: opts.order_ascend}).cenaSql( 'get', callback100 );
Client Side: local DB table structure
create table if not exists cena_env(cena_name text unique, cena_id, scheme, model, type, id integer, act, column, value, state );
Server Side: cenaPhp
Dba\Dao,Sql,PdoCena\RecordDba\ModelDba\Record
sql wrapper
data model
active record
Cena maps ORM
internetbrowser
Server Side: saving data to DB
static function proc_cena( &$cena_recs, $doAct=NULL ) {$do_models = self::$models;foreach( $do_models as $model ) { // for all modelsforeach( $get_types as $type => $get_ids ) { // for all typesforeach( $get_ids as $id => $actions ) { // for all ids$cena = Cena::getCena( $model, $type, $id );$cena->manipulate( $actions );try {if( have_value( $doAct ) ) $cena->do_function( $doAct );} catch( orm\DataInvalid_DbaRecord_Exception $e ) {$num_err ++;}$cena_recs[ $model ][] = $cena;} // end loop on ids} // end loop on types} // end loop on models}
summary
Similar Technologies...
Random IDused by persistent.js, parse.com, Google Calendar
GUID (Globaly Unique ID) by Microsoftused by MS Access
sqlAnywhere by Sybaseuse ODBC to issue SQL statement to master db?
conversion table patent by SAP?a patent I found somewhere...
Cena-DTA's Strength
Cena-DTA
RDBRDB
KVRDB
ORM
and Weaknesses...
get/new
ORMActive Record
Future Plan
Improve demoSupport Web Indexed Database.
Security issue.
AJAX download/upload data, many-to-many, i18n support, etc.
Refactor code and protocol
Other language/platform???
Need killer demo/application/service!
End of Presentation
Cena-DTA #PHPCon 2011-09-10