• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Domain NoSQL: Next Generation Domain Modelling
 

Domain NoSQL: Next Generation Domain Modelling

on

  • 6,287 views

Until recently, Relational Databases have been the rage... but now there's a new ...

Until recently, Relational Databases have been the rage... but now there's a new
kid on the block: the NoSQL database. NoSQL databases turn the conventions we've
all learned on their heads: data normalization, pivot tables, schemas, and more.
Instead of storing metadata and relations across tables, we can create custom
schemas per record -- offering incredible flexibility and reducing the number of
queries required to get at exactly the information we need.

In this talk, we'll look at some of the advantages and disadvantages of NoSQL
databases, as well as some examples of applications that could benefit from the
new paradigms they offer.

Statistics

Views

Total Views
6,287
Views on SlideShare
5,912
Embed Views
375

Actions

Likes
8
Downloads
145
Comments
0

10 Embeds 375

http://www.slideshare.net 171
http://linux.socioambiental.org 155
http://victimofbabylon.com 37
http://coderwall.com 4
http://victimofbabylon.posterous.com 3
http://localhost 1
http://translate.googleusercontent.com 1
http://paper.li 1
http://www.lmodules.com 1
http://www.php-talks.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Possible Email Newsletter & Photo slideshows
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter
  • Been working on a new design for 6 months. Host of new features that old did not have. Look and feel have been reinvented New concepts in place like member directory, online calendar, online map – both using tech from Google Info more easily updated Special pags - Committee pages, ministry pages, youth pages, missions pages Home page that gives quick access to current news, information, and links Archives section to store video, audio, documents, images that can be searched Members area for sensitive information Newsletter

Domain NoSQL: Next Generation Domain Modelling Domain NoSQL: Next Generation Domain Modelling Presentation Transcript

  • Next Generation Domain Modeling tekx Domain NoSQL Matthew Weier O'Phinney Project Lead, Zend Framework
  • The typical first steps in PHP
  • design the schema (http://musicbrainz.org/)
  • take input, and shove it in a DB (http://musicbrainz.org/)
  • write queries to pull from the DB (http://musicbrainz.org/) $result = mysql_query( "SELECT * FROM sometable" ); $rows = false; if (mysql_num_rows( $result ) > 0) { $rows = array (); while ( $row = mysql_fetch_assoc( $result )) { $rows [] = $row ; } }
  • spit data onto a page (http://www.irs.gov/)
  • profit!
    • … and watch the app get hacked with SQL injections
    • … or watch the app grind to a halt under expensive queries
    • … usually both
  • Next steps in PHP development
  • design the schema (http://musicbrainz.org/)
  • use ActiveRecord $user = new User(); $user ->name = 'matthew' ; $user ->email = 'matthew@zend.com' ; $user ->save(); $users = User::find( array ( $id1 , $id2 , $id3 ));
  • spit data onto a page (http://www.irs.gov/)
  • profit!
    • … most SQL injection vectors are gone, but you've got new, expensive queries to deal with
    • … you're really just abstracting the original problems
  • evolve
  • Use Domain Driven Design (DDD), or Behavior Driven Design (BDD)
  • Develop your application logic first, in order to determine what needs to be persisted. the primary rule
  • define your application entities
  • implement them in code use ZendSessionSessionManager, ZendSessionConfigurationStandardConfiguration, ZendSessionStorageSessionStorage, ZendSessionContainer; $manager = new SessionManager(); $manager ->setConfig( new StandardConfiguration()) ->setStorage( new SessionStorage()); $container = new Container( 'auth' , $manager );
  • test! (better: test first!)
  • map entities to data store public function fromArray( array $data ) { $filter = new OptionsFilter(); foreach ( $data as $key => $value ) { $method = 'set' . $filter ( $key ); if (method_exists( $this , $method )) { $this -> $method ( $value ); } } } public function toArray() { return array ( '_id' => $this ->getId(), 'timestamp' => $this ->getTimestamp(), 'title' => $this ->getTitle(),
  • spit data onto a page (http://www.irs.gov/)
  • profit!
    • … sit back, enjoy a beverage, and relax!
    • … or start building those next, great features of your application.
  • Rules of Domain Logic
  • use Plain Old PHP Objects class User { public function getId() {} public function setId( $value ) {} public function getRealname() {} public function setRealname( $value ) {} public function getEmail() {} public function setEmail( $value ) {} }
  • use 3 rd party code via composition use ZendValidatorValidationChain; class Entry { public function setValidator(ValidationChain $chain ) { $this ->_validator = $chain ; return $this ; } public function fromArray( array $data ) { if (! $this ->getValidator()->isValid( $data )) { throw new Exception( 'Invalid data!' ); } // ... } }
  • Define a schema based on the objects you use (http://musicbrainz.org/)
  • use mappers or transaction scripts to translate objects to data & back $user = new User(); $user ->setId( 'matthew' ) ->setName( "Matthew Weier O'Phinney" ); $mapper ->save( $user ); $user = $repository ->find( 'matthew' );
  • use service objects to manipulate entities namespace BlogService; class Entries { public function fetchEntry( $permalink ) {} public function fetchCommentCount( $permalink ) {} public function fetchComments( $permalink ) {} public function fetchTrackbacks( $permalink ) {} public function addComment( $permalink , array $comment ) {} public function addTrackback( $permalink , array $comment ) {} public function fetchTagCloud() {} }
  • What does NoSQL have to do with it?
  • you have a choice
    • Before, relational databases were the only choice
  • you have a choice
    • Today , relational databases are only one choice
    • defining by what it isn't?
    • still defining by what it isn't …
  • types: key/value stores
    • each record is a key/value pair, (though the value may be non-scalar)
  • types: document databases
    • Each document can define its own structure
    • Typically a document consists of many key/value pairs
    { _id: "weierophinney" , realname: "Matthew Weier O'Phinney" , email: "matthew@zend.com" , roles: [ "admin" , "user" ] }
  • document dbs are plentiful
  • document dbs solve web content problems
    • Free yourself from the problems caused by Entity-Attribute-Value tables; store metadata where it belongs, with the document!
    • Allow different but related content types to co-exist in the same general storage.
    • Aggregate related content in the document that owns it (e.g., tags, comments, etc.)
  • considerations with domain models
    • Most Document Storage supports either JSON or arrays
    • Most support specifying either an ID or using a UUID
    • Disk usage (think: metadata describing each document)
    • Do you need a mapper?
  • Examples
  • fetch by ID with domain objects use BlogEntityEntry; $entry = new Entry(); $entry ->setTitle( 'NoSQL and Domain Objects' ); // implicitly sets ID to // "nosql-and-domain-objects" $mapper ->save( $entry ); $entry = $repository ->find( 'nosql-and-domain-objects' );
  • RDBMS schema
  • inserting an entry with couchdb { title: "Domain NoSQL" , author: "matthew" , tags: [ "tekx" , "nosql" , "ddd" ] }
  • inserting an entry with mongodb $collection ->save( array ( 'title' => 'Domain NoSQL' , 'author' => 'matthew' , 'tags' => array ( 'tekx' , 'nosql' , 'ddd' ), ));
  • fetching by ID with couchdb $response = $client ->get( 'http://localhost:5984/blog/no-sql-and-domain-objects' ); $json = $response ->getBody(); $entry = json_decode( $json );
  • fetching by ID with mongodb $mongo = new Mongo(); $db = $mongo ->selectDB( 'blog' ); $entries = $db ->selectCollection( 'entries' ); $entry = $entries ->find( 'nosql-and-domain-objects' );
  • tags in domain objects class Entry { public function setTags( array $tags ) { foreach ( $tags as $tag ) { $this ->addTag( $tag ); } } public function addTag( $tag ) { $this ->_tags[] = ( string ) $tag ; } }
  • querying by tag with couchdb /* Define a view */ { "_id" : "_design/blog" , "views" : { "byTag" : { "map" : "function(doc) { if (!doc.tags) { return; } doc.tags.forEach(function(tag) { emit(tag, doc); }); }" } } } /* retrieve: /blog/_design/blog/_view/byTag?key="tagname" */
  • querying by tag with mongodb $tagged = $entries ->find( array ( 'tag' => 'sometag' ));
  • Closing Notes
    • Don't start your development from the wrong end. Start with objects.
    • Be aware of all the options you have for persisting data; choose appropriately.
    • Consider document data stores when your objects represent content; store metadata in the document.
  • Thank you Feedback? http://joind.in/1581 http://twitter.com/weierophinney http://framework.zend.com/