{"id":73106,"date":"2016-09-02T14:40:20","date_gmt":"2016-09-02T14:40:20","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/uncategorized\/json-for-absolute-beginners-part-2-why-use-oracle\/"},"modified":"2021-07-14T13:07:03","modified_gmt":"2021-07-14T13:07:03","slug":"json-for-absolute-beginners-part-2-why-use-oracle","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/oracle-databases\/json-for-absolute-beginners-part-2-why-use-oracle\/","title":{"rendered":"JSON For Absolute Beginners: Part 2 &#8211; Why Use Oracle?"},"content":{"rendered":"<p>In this short series of articles, we\u2019ll be talking about JSON and its integration with the Oracle database. \u00a0The <a href=\"https:\/\/allthingsoracle.com\/json-for-absolute-beginners-part-1-introduction\/\">first part<\/a> was an introduction to JSON itself, and was, admittedly, very light on Oracle. \u00a0But now\u00a0it\u2019s probably time to bring Oracle more into the story and talk about how the database has adapted to handle this new format.<\/p>\n<p>Or, actually, instead of talking <i>how,<\/i> maybe we should be talking about <i>why.<\/i><\/p>\n<p>Think about it. \u00a0The beauty &#8211; the <i>efficiency &#8211;<\/i> of a relational database such as Oracle is the way it takes an object, breaks it down it its smallest, indivisible elements and stores those elements across a logical landscape of columns and tables. As Oracle developers, we would look at:<\/p>\n<pre>{\r\n\u00a0\"firstname\":\"David\",\r\n\u00a0\"lastname\":\"Njoku\",\r\n\u00a0\"occupation\":\"Software developer\"\r\n\u00a0\"gender\":\"Male\"\r\n}\r\n<\/pre>\n<p>and immediately begin to dream of, perhaps, a <i>Person<\/i> table with <em>f<\/em><i>irst_name<\/i> and <em>l<\/em><i>ast_name<\/i> columns; and a different table for <em>Occupations<\/em>; and then yet another table, maybe called <em>Person_Occupation<\/em> to link both tables; and then we\u2019ll need a lookup table for the various occupations, and another lookup table for genders. Oh, and we haven\u2019t even mentioned the primary key columns we\u2019ll need to invent, or the triggers we\u2019d have to write to manage them, or the constraints that\u2019ll be needed to knit everything together and ensure data integrity; and &#8211;<\/p>\n<p><i>Enough!<\/i> Our JSON object is only 9 words long, but we already need 5 tables, 5 triggers and a spider\u2019s web of crisscrossing constraints just to hold it. It\u2019s madness!<\/p>\n<p>Or, at least, so say the proponents of NoSQL databases. NoSQL databases eschew the tabular relational model that we\u2019ve come to know and love with RDBMS like Oracle. With NoSQL you don\u2019t spend hours building a cityscape of tables to hold a piddly bit of data. No sir. A NoSQL database (or, at least, a <i>document-oriented<\/i> NoSQL database) will store the whole JSON object together as a single entity.<\/p>\n<p>NoSQL databases (or, at least, their forebears) have been around for decades &#8211; in fact, they predate relational databases, and RDBMS were invented to resolve the perceived problems with non-relational databases. \u00a0However, with the growth of web 2.0 data behemoths like Google and Facebook, and with the birth of data formats such as JSON, NoSQL has had a huge resurgence over the last few years. \u00a0So much so that the web is strewn with thinkpieces predicting the death of relational databases and the dawning of the new age of NoSQL. (<a href=\"http:\/\/www.techrepublic.com\/article\/will-nosql-be-the-undoing-of-oracles-database-reign\/\" target=\"_blank\">Here<\/a> <a href=\"http:\/\/sqlmag.com\/sql-server\/could-unstructured-data-management-technology-replace-relational-database-someday\" target=\"_blank\">are<\/a> <a href=\"http:\/\/techalpine.com\/how-nosql-fills-the-gaps-in-traditional-rdbms\/\" target=\"_blank\">a<\/a> <a href=\"http:\/\/www.eweek.com\/database\/slideshows\/why-relational-databases-dont-handle-big-data-well.html\" target=\"_blank\">few<\/a>.)<\/p>\n<p>All of which brings us back to the question: if JSON (along with XML and YAML) is one of the main reasons for the rebirth of non-relational databases, why are we here? Shouldn\u2019t we be reading about this on a site called something like <i>All Things MongoDB?<\/i> (MongoDB is one of the more popular document-oriented databases; others include CouchDB, RavenDB and many others. Other NoSQL databases include Google\u2019s BigTable, Hadoop, and Facebook\u2019s Cassandra.)<\/p>\n<p>Why on earth would you use Oracle for your JSON?<\/p>\n<p>That\u2019s a good question &#8211; even if it\u2019s one that the accountants at Oracle would rather you didn\u2019t ask. NoSQL document-stores\u00a0are simple, they are built from the start to handle documents and the sort of key-value data that JSON is comprised of, and they are excellent at handling big data (hence Google and Facebook\u2019s interest). So why on earth would you use Oracle for your JSON?<\/p>\n<p>Before I attempt to answer the question, let me quickly restate some of the advantages of a NoSQL solution:<\/p>\n<ul>\n<li>It is schema-less (or, at least, is very flexible when it comes to schemas).<\/li>\n<li>It stores the whole document in one place, rather than scattering it across multiple tables like shrapnel.<\/li>\n<li>It is focussed on the key-value structure.<\/li>\n<\/ul>\n<p>So, in the face of all of this, why on earth would you use Oracle for your JSON?<\/p>\n<p>Good question, right? Actually, no, it\u2019s <i>not<\/i> a good question. There are a million articles on the web taking sides in the RDBMS vs NoSQL debate, and, since you\u2019re here, I\u2019m going to assume that you\u2019ve read some of them or, at least, are aware of the debate. But here\u2019s the truth: in many, many cases, it is an irrelevant question.<\/p>\n<p>If you\u2019re an Oracle developer, working with a team of Oracle developers, in an organisation built on an Oracle database with a foundation of years of Oracle experience, then shouldn&#8217;t the question be <i>can Oracle meet my needs?<\/i> \u00a0The question should be, can Oracle match (or mimic) the attributes of a NoSQL database while retaining the unquestioned benefits of a relational database?<\/p>\n<p>And, after years of denigrating NoSQL databases (here\u2019s Oracle Chairman <a href=\"https:\/\/youtu.be\/LrDnuvHfBr4?t=2m27s\" target=\"_blank\">Larry Ellison in 2012<\/a>, and here\u2019s <a href=\"http:\/\/www.eweek.com\/database\/oracle-defends-relational-dbs-against-nosql-competitors.html\" target=\"_blank\">Vice-President Andy Mendelsohn<\/a>), Oracle finally turned their attention to answering that question. Starting with 12.1.0.2 they introduced the Oracle JSON Document Store. \u00a0It is their way of harnessing the excitement of a NoSQL database, while, hopefully, losing none of the sturdiness of an RDBMS.<\/p>\n<p>In the next article in this series, we\u2019ll delve into that solution and see if they\u2019ve succeeded.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this short series of articles, we\u2019ll be talking about JSON and its integration with the Oracle database. \u00a0The first part was an introduction to JSON itself, and was, admittedly, very light on Oracle. \u00a0But now\u00a0it\u2019s probably time to bring Oracle more into the story and talk about how the database has adapted to handle this new format. Or, actually,&hellip;<\/p>\n","protected":false},"author":221907,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143533],"tags":[4880],"coauthors":[],"class_list":["post-73106","post","type-post","status-publish","format-standard","hentry","category-oracle-databases","tag-json"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/73106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/221907"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=73106"}],"version-history":[{"count":1,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/73106\/revisions"}],"predecessor-version":[{"id":91605,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/73106\/revisions\/91605"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=73106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=73106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=73106"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=73106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}