DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. Databases
  4. NoSQL for Storage, Relational for Reporting? No Friggin' Way.

NoSQL for Storage, Relational for Reporting? No Friggin' Way.

Paul Hammant user avatar by
Paul Hammant
·
Jun. 13, 12 · Interview
Like (0)
Save
Tweet
Share
15.11K Views

Join the DZone community and get the full member experience.

Join For Free

given i think there is a shift afoot towards client-side mvc dealing in whole json documents up and down the wire, i’m wondering if there is also need for a technology to transparently create/maintain relational record sets for the pertinent document writes. relational records are desirable as they would support easy sql -using reporting tools. tools like crystal or jasper reports.

i’m not so much interested in the enhancements to sql that allow for json fragments in queries . nor am i interested the custom search engine solutions like elasticsearch that allow for sophisticated querying of an index. i’m looking for something that does secondary writes to a normal relational schema (whether defined or automatically generated), in such a way that crystal or jasper reports (or equivalent) could easily consume records for reporting. the resulting schema (aside from the cost of the secondary writes), would be optimized for queries.

martin fowler, as ever, sets the foundation for what i’m wanting with a bliki entry reportingdatabase

a worked example

here’s json fragment similar to the first one on: http://en.wikipedia.org/wiki/ json

{
	 "id"       : 101,
     "firstname": "john",
     "lastname" : "smith",
     "age"      : 25,
     "address"  :
     {
         "streetaddress": "21 2nd street",
         "city"         : "new york",
         "state"        : "ny",
         "postalcode"   : "10021"
     },
     "phonenumber":
     [
         {
           "type"  : "home",
           "number": "212 555-1234"
         },
         {
           "type"  : "fax",
           "number": "646 555-4567"
         }
     ]
}

if that resource were overwritten in a nosql database, then it would be one i/o. a trigger could pick that write up and, in postgres at least, could handle the economic updates as well as the deletes/writes as applicable into a relational schema. in this case that would be four writes (hopefully to a separate database/server to the document store):

person

id firstname lastname age
101 john smith 25

personaddress

id streetaddress city state postalcode
101 21 2nd street new york ny 10021

personphonenumber

id ix type number
101 0 home 212 555-1234
101 1 fax 646 555-4567

extracting relational fields from json declaratively.

ideally, there would be a declarative xpath -like language that would allow us to tersely declare the sections of a json document we would want to explode into rows in a relational schema. two alternates exist already – jaql or jsonpath , but we’d want to use them in a way that would batch process documents into cohesive sql statements:

{
     "tables":
     [
         {
           "name"  : "person",
           "key": "id"
		   "fields": "firstname, lastname, age"
         },
         {
           "name"  : "personaddress",
           "key": "id"
           "fields": "address.streetaddress, address.city, address.state, address.postalcode"
         },
         {
           "name"  : "personphonenumber",
           "key": "id, phonenumber.@index as ix"
		   "fields": "phonenumber[ix].type, phonenumber[ix].number"
         }
     ]
}

whether ddl could be automatically extracted to issue the correct create table statements is debatable. it’s also not clear whether json will be a successful notation for extracting relational data from json documents.

put versus post

web apps are classically constructed from get and post applications. here is a timeline of web technologies in two blog entries – 1993, 2000, 2006 and its follow-up 2012 , lastly one extolling the virtues of document is the single source of truth . in the second and third i talk about the potential for put as a mechanism for writing back documents that were ‘worked on’ in a page. in relation to today’s blog entry, the put of the whole document all the way back to the database is powerful because it facilitates a trigger on the old and the new document in one operation. you may be driven to post because of a larger document size, and have to do additional processing in your persistence tier to make sense of that in a document store, but the consequential conversion to a relational form would still be possible.

of course, whether put or post , json docs or fragments would still need re-validating on the server-side as well as auth/audit/access control.

it’s important to note that many esteemed thoughtworks colleagues counsel against put and for post to do discrete updates to a backend document.

blast from the past: oracle’s intermedia.

eleven years ago oracle had a technology intermedia that would (amongst other things) take a write of xml to a clob and write out additional records to related tables to allow direct indexing of xml attributes/elements. they don’t so much talk of it any more. i can’t remember whether that was done in real-time or not, but it feels like it was in the same space as what i’m wanting.

microsoft’s sql server analysis services

like oracle’s intermedia, microsoft have a technology sql server analysis services . unlike intermedia, it is most definitely current.

amongst many other olap things, it explodes xml clobs into eminently searchable cubes. using this mas (?) piece, it is easy to make cubes for various sets of data, and from that perform easy reporting very much offline. in the end though, it is not quite what i’m looking for.

follow ups.

nic ferrier for one is itching to write something more technical for the nosql to relational idea. i’ll link to it when he finishes it.

Relational database Database NoSQL Document sql

Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Cloud Performance Engineering
  • DevOps vs Agile: Which Approach Will Win the Battle for Efficiency?
  • Front-End Troubleshooting Using OpenTelemetry
  • Understanding and Solving the AWS Lambda Cold Start Problem

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: