Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Development without Constraint

1,523 views

Published on

Introduction to Development with the Content Repository API for Java ( JCR ) and Discussion of the RDBMS Versus NoSQL Decision Space

  • Be the first to like this

Development without Constraint

  1. 1. Chad Davis● Java Software Engineer● Colorado Springs Open Source Meetup● Blackdog Software, Inc.● Author – Struts 2 in Action – Sun Certified Mobile Application Developer Exam Guide● Corporate Trainer – Struts 2● Content Management System● Am I a DBA?
  2. 2. Development without Constraint ( or Integrity? ) An Introduction to the Content Repository API for Java (JCR) & “RDBMS v. Object Storage” Discussion
  3. 3. Our Itinerary● Introduction to the Content Repository API for Java ( JCR )● Development without Constraint ( or Integrity? )● “Is my project a match for the JCR?”
  4. 4. The Java Content Repository ( JCR )● Java Specification● JSR 170 ( 1.x )● JSR 268 ( 2.x )● How did this come to be a part of Java?
  5. 5. Jackrabbit● Open Source (Apache Project)● Reference Implementation● “A content repository is a hierarchical content store . . .”● For “content-oriented” applications● Anybody want to take a stab at defining “content- oriented”?
  6. 6. Content?● Blame the Web● Blame the Scope Creep of IT● Documents● Binaries / Digital Assets● Unpredictable Structure● Meta-data
  7. 7. Bells and Whistles● Version Control● Full Text Search● Observation (Event Handling)● Unstructured / Structured Content● Transactions● Workspaces● And more . . .
  8. 8. Data Model● Hierarchical● Unstructured● Or Structured
  9. 9. Hierarchical Data is Natural● File Systems● XML● DNS● DOM● Biology● Taxonomy
  10. 10. The Hierachy ● Full Paths are IDs ● Hiearchy is Semantic ● Fast Navigation/Location ● Human Readable
  11. 11. JCR Node Trees ● Nodes ● Properties ● Values ● Names ● Structure
  12. 12. Property TypesSTRING●URI●BOOLEAN●LONG●DOUBLE●DECIMAL●BINARY●DATE●NAME, PATH●WEAKREFERENCE, REFERENCE●
  13. 13. More Property Stuff● Multi-Valued● Value Constraints
  14. 14. Structural Constraints: Nodes● Node Types – Primary – Mixin● Child Nodes – Name and Type● Properties – Name and Type● Inheritance
  15. 15. Compact Namespace & Node Type Definition (CND)<cd = http://chaddavis.com>[cd:contact] > nt:unstructured ­cd:email ( string ) multiple ­cd:pic ( binary ) mandatory 
  16. 16. Referential Integrity● Contained in Structure● Use Properties● REFERENCE● WEAKREFERENCE● paths/UUID
  17. 17. API Tour: Main Classes
  18. 18. API Tour: Reading● Direct Access bobNode=session.getNode(“/contacts/personal/Bob Smith” ); bobEmail = session.getProperty(“/contacts/personal/Bob  Smith/email”);● Retrieve by ID bobNode = session.getNodeByIdentifier(bobUUID);● By Relative Path bobNode = personalNode.getNode(“Bob Smith”); emailProperty = bobNode.getProperty(“email”);● Reading Values emailValue = emailProperty.getValue();  emailValue.getString(); inputStream = picValue.getBinary().getStream();    
  19. 19. JCR Node Trees ● Nodes ● Properties ● Values ● Names ● Structure
  20. 20. API Tour: Navigation● Iterator Over Child Nodes NodeIterator personalContactsItty = personal.getNodes();● Iterator Over Properties PropertyIterator propItty = bobNode.getProperties;
  21. 21. API Tour: Creating● Create Node and Properties chadNode = personalContactsNode.addNode(“Chad Davis”); chadNode.setProperty ( “email”, “chad@mail.com”); //binaries Binary picBinary = valueFactory.createBinary(picInputStream); Value fileValue = valueFactory.createValue(picBinary); contentNode.setProperty("jcr:data", fileValue);
  22. 22. API Tour: Query● SQL, XPath, JQOM● Full Text Search xpathExp = “/contacts/personal/element(*,nt:unstructured[jcr:contains(.,hotmail)]"; queryMng = session.getWorkspace().getQueryManager(); query = QueryMng.createQuery(xpathExp, Query.XPATH); results = query.execute();● All Properties and Node Names Included in Full Text Search● Binaries Too!
  23. 23. API Tour: Query● Saving Queries to Repo query.storeAsNode(“/queries/chad/query1”);
  24. 24. API Tour: Version Control● Labels● Merge● Check In New Version versionMngr = session.getWorkspace().getVersionManager(); newVersion = versionManager.checkin( nodeToCommit.getPath() ); versionHist = versionMngr.getVersionHistory( nodeToCommit.getPath() ); versionHistory.addVersionLabel( newVersion.getName(), label, false );
  25. 25. API Tour: Version Control● Restore to Other Version versionMngr = session.getWorkspace().getVersionManager(); VersionHistory = versionMngr.getVersionHistory( targetNode.getPath()); targetVersion = versionHistory.getVersionByLabel(versionLabel); versionManager.restore(targetVersion, false);
  26. 26. End of JCR Tour● Jackrabbit● Content Management Systems● Artifact Management● Operations Management
  27. 27. RDBMS v. Object Storage“Schema-less databases and document-oriented databases are aparadigm shift, and it provides bigger programmer challenges thansomething like picking up a new language. I would liken it to thetransition from procedural to object oriented programming.” --Scott Swigart, “How Software is Built”
  28. 28. Paradigm Shift?
  29. 29. The Relational Model● Hegemonic Concept● Mathematical● Taught in Every DB Course● 1970s
  30. 30. Edgar Frank "Ted" Codd ● IBM ● Invented the Relational  Model ● "A Relational Model of Data  for Large Shared Data Banks" ● 1970 ● “Is Your DBMS Really  Relational?" ● “Does Your DBMS Run By the  Rules?”
  31. 31. Goals of Relational Model● Mathematical – Efficiency – Resource Friendly – Powerful Operations● Program-Data Independence – More than one app can access data – Consider file based data persistence
  32. 32. Goals of Relational Model● Data Integrity● Column Constraints● Referential Integrity● Normalization – Insert, Update and Delete Anomalies – Data redundancy – 3NF
  33. 33. Structure Driven Development● Database Design● Upfront Concretization of Data Model● DDL● Tables● Structure Comes Before Data● Heavy Weight● Formal
  34. 34. Does Your DBMS Run By the Rules?
  35. 35. Impedance Mismatch● Object-Relational – Hibernate● Data Types – 1970 – No Web – 2010 – Content, Documents, Tweets – JSON As Storage Format?● Structure First – Data First – Agile Development● Program-Data independence – This architectural imperitive has also shifted, but I cant quite express it . . .
  36. 36. New Stuff● NoSQL● Schemaless DB● Object DB● Content Repository● Document-Oriented DB
  37. 37. Some Offerings● CouchDB● MongoDB● Hadoop● SimpleDB ( Amazon )
  38. 38. The Case for Jackrabbit● Coy Data – Data Driven Development – Agile● Naturally Hierarchical Data● “Content” Oriented Data● Navigation / Query● Integrity?
  39. 39. The Case for RDBMS● Interrelated Data● Lots of Joins● Flat Data● Operations
  40. 40. R U Relaxed?
  41. 41. References● Database:Principles, Programming, Performance. Patrick ONeil and Elizabeth ONeil.● JCR or RDBMS: Why, When, How? Bertil Chapuis● Interview with CouchDBs Damien Katz● CouchDB Rap

×