{"id":2047,"date":"2013-04-11T09:36:02","date_gmt":"2013-04-11T09:36:02","guid":{"rendered":"http:\/\/www.odbms.org\/blog\/?p=2047"},"modified":"2013-04-11T09:36:02","modified_gmt":"2013-04-11T09:36:02","slug":"graphs-vs-sql-interview-with-michael-blaha","status":"publish","type":"post","link":"https:\/\/www.odbms.org\/blog\/2013\/04\/graphs-vs-sql-interview-with-michael-blaha\/","title":{"rendered":"Graphs vs. SQL. Interview with Michael Blaha"},"content":{"rendered":"<blockquote><p>\n<strong><em>&#8220;For traditional business applications, the schema is known in advance, so there is no need to use a graph database which has weaker enforcement of integrity. If instead, you&#8217;re dealing with at best a generic model to which it conforms, then a schema-oriented approach does not provide much. Instead a graph-oriented approach is more natural and easier to develop against.&#8221;<\/em>&#8212; Michael Blaha<\/strong>\n<\/p><\/blockquote>\n<p><em>Graphs, SQL and Databases<\/em>. On this topic I have interviewed our expert <strong><a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.odbms.org\/About\/Contributors\/blaha.aspx');\"  href=\"http:\/\/www.odbms.org\/About\/Contributors\/blaha.aspx\">Michael Blaha<\/a><\/strong>.<\/p>\n<p>RVZ<\/p>\n<p><strong>Q1. A lot of today&#8217;s data can be modeled as a heterogeneous set of &#8220;vertices&#8221; connected by a heterogeneous set of &#8220;edges&#8221;, people, events, items, etc. related by knowing, attending, purchasing, etc.  This world view is not new as the <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/en.wikipedia.org\/wiki\/Object-oriented_modeling');\"  href=\"http:\/\/en.wikipedia.org\/wiki\/Object-oriented_modeling\">object-oriented <\/a>community has a similar perspective on data. What is in your opinion the main difference with respect to a graph-centric data world?<\/strong><\/p>\n<p><strong>Michael Blaha:<\/strong> This world view is also not new because this is the approach<a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/en.wikipedia.org\/wiki\/Charles_Bachman');\"  href=\"http:\/\/en.wikipedia.org\/wiki\/Charles_Bachman\"> Charlie Bachman<\/a> took with <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/en.wikipedia.org\/wiki\/Network_model');\"  href=\"http:\/\/en.wikipedia.org\/wiki\/Network_model\">network databases<\/a> many years ago. I can think of at least two major distinguishing aspects of graph-centric databases relative to relational databases.<br \/>\n(1) <em>Graph-centric databases are occurrence-oriented while relational databases are schema-oriented.<\/em>  If you know the schema in advance and must ensure that data conforms to it, then a schema-oriented approach is best. Examples include traditional business applications, such as flight reservations, payroll, and order processing.<br \/>\n(2) <em>Graph-centric databases emphasize navigation.<\/em> You start with a root object and pull together a meaningful group of related objects. Relational databases permit navigation via joins, but such navigation is more cumbersome and less natural. Many relational database developers are not adept at performing such navigation.<\/p>\n<p><strong>Q2. The development of scalable graph applications such for example for Facebook, and Twitter require different kind of databases than SQL. Most of these large Web companies have built their own internal graph databases. But what about other enterprise applications?<\/strong><\/p>\n<p><strong>Michael Blaha:<\/strong> The key is the distinction between being occurrence-oriented and schema-oriented. For traditional business applications, the schema is known in advance, so there is no need to use a graph database which has weaker enforcement of integrity. If instead, you&#8217;re dealing with at best a generic model to which it conforms, then a schema-oriented approach does not provide much. Instead a graph-oriented approach is more natural and easier to develop against.<\/p>\n<p><strong>Q3: Marko Rodriguez and Peter Neubauer in an<a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.odbms.org\/blog\/2011\/06\/applying-graph-analysis-and-manipulation-to-data-stores\/');\"  href=\"http:\/\/www.odbms.org\/blog\/2011\/06\/applying-graph-analysis-and-manipulation-to-data-stores\/\"> interview <\/a>say that <em><\/em><em>&#8220;the benefit of the graph comes from being able to rapidly traverse structures to an arbitrary depth (e.g., tree structures, cyclic structures) and with an arbitrary path description (e.g. friends that work together, roads below a certain congestion threshold).  We call this data processing pattern, the graph traversal pattern. This mind set is much different from the set theoretic notions of the relational database world. In the world of graphs, everything is seen as a walk&#8217;s traversa<\/em>l&#8221;. What is your take on this?  <\/strong><\/p>\n<p><strong>Michael Blaha:<\/strong> That&#8217;s a great point and one that I should have mentioned in my answer to Q1. Relational databases have poor handling of recursion. I will note that the vendor products have extensions for this but they aren&#8217;t natural and are an awkward graft onto SQL. <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/en.wikipedia.org\/wiki\/Graph_database');\"  href=\"http:\/\/en.wikipedia.org\/wiki\/Graph_database\">Graph databases<\/a>, in contrast, are great with handling recursion.  This is a big advantage of graph databases for applications where recursion arises.<\/p>\n<p><strong>Q4. Is there any synergy between graphs and conventional relational databases?<\/strong><\/p>\n<p><strong>Michael Blaha:<\/strong> Graphs are also important for relational databases, and more so than some persons may realize&#8230;<br \/>\n&#8212; <em>Graphs are clearly relevant for data modeling<\/em>. An Entity-Relationship data model portrays the database structure as a graph.<br \/>\n&#8212; <em>Graphs are also important for expressing database constraints<\/em>. The OMG&#8217;s <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/en.wikipedia.org\/wiki\/Object_Constraint_Language');\"  href=\"http:\/\/en.wikipedia.org\/wiki\/Object_Constraint_Language\">Object Constraint Language<\/a> (OCL) expresses database constraints using graph traversal. The OCL is a textual language so it can be tedious to use, but it is powerful.  The <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/en.wikipedia.org\/wiki\/Common_Warehouse_Metamodel');\"  href=\"http:\/\/en.wikipedia.org\/wiki\/Common_Warehouse_Metamodel\">Common Warehouse Metamode<\/a>l (CWM) specifies many fine constraints with the OCL and is a superb example of proper OCL usage.<br \/>\n&#8212; Even though the standard does not emphasize it, the OCL is also an excellent language for database traversal as a starting point for database queries. Bill Premerlani and I explained this in a past book (<a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.prenhall.com\/books\/esm_0131238299.html');\"  href=\"http:\/\/www.prenhall.com\/books\/esm_0131238299.html\">Object-Oriented Modeling and Design for Database Applications<\/a>).<br \/>\n&#8212; Graphs are also helpful for characterizing the complexity of a relational database design. Robert Hilliard presents an excellent technique for doing this in his book (<a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.infodrivenbusiness.com');\"  href=\"http:\/\/www.infodrivenbusiness.com\">Information-Driven Business<\/a>).<\/p>\n<p><strong>Q5. You say that graphs are important for data modeling, but at the end you do not store graphs in a relational database but tables, and you need joins to link them together&#8230; Graph databases in contrast cache what is on disk into memory and vendors claim that this makes for a highly reusable in-memory cache. What is your take on this?<\/strong><\/p>\n<p><strong>Michael Blaha:<\/strong> Relational databases play many optimization games behind the covers.  So in general, possible performance differences are often not obvious. I would say that the difference in expressiveness is what determines suitable applications for graph and relational databases and performance is a secondary issue, except for very specialized applications.<\/p>\n<p><strong>Q6: What are advantages of SQL relative to graph databases?<\/strong><\/p>\n<p><strong>Michael Blaha:<\/strong>  Here are some advantages of SQL:<\/p>\n<p>&#8212; SQL has a widely-accepted standard.<br \/>\n&#8212; SQL is a set-oriented language. This is good for mass-processing of set-oriented data.<br \/>\n&#8212; SQL databases have powerful query optimizers for handling set-oriented queries, such as for data warehouses.<br \/>\n&#8212; The transaction processing behavior of relational databases (the ACID properties) are robust, powerful, and sound.<br \/>\n&#8212; SQL has extensive support for controlling data access.<\/p>\n<p><strong>Q7: What are disadvantages of SQL relative to graph databases?<\/strong><\/p>\n<p><strong>Michael Blaha:<\/strong> Here are some disadvantages of SQL:<\/p>\n<p>&#8212; SQL is awkward for processing the explosion of data that can result from starting with an object and traversing a graph.<br \/>\nSQL, at best, awkwardly handles recursion.<br \/>\n&#8212; SQL has lots of overhead for multi-user locking that can make it difficult to access individual objects and their data.<br \/>\n&#8212; Advanced and specialty applications often require less rigorous transaction processing with reduced overhead and higher throughput.<\/p>\n<p><strong>Q8: For which applications is SQL best? For which applications are graph databases best?<\/strong><\/p>\n<p><strong>Michael Blaha:<\/strong><br \/>\n&#8212; SQL is schema based. Define the structure in advance and then store the data. This is a good approach for conventional data processing such as many business and financial systems.<br \/>\n&#8212; Graph databases are occurrence based. Store data and relationships as they are encountered. Do not presume that there is an encompassing structure. This is a good approach for some scientific and engineering applications as well as data that is acquired from Web browsers and search engines.<\/p>\n<p><strong>Q9. What about <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/en.wikipedia.org\/wiki\/Resource_Description_Framework');\"  href=\"http:\/\/en.wikipedia.org\/wiki\/Resource_Description_Framework\">RDF quad\/triple stores<\/a>?<\/strong><\/p>\n<p><strong>Michael Blaha:<\/strong> I have not paid much attention to this. <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.w3.org\/RDF\/');\"  href=\"http:\/\/www.w3.org\/RDF\/\">RDF<\/a> is an entity-attribute-value approach. From what I can tell, it seems occurrence based and not schema based and my earlier comments apply. <\/p>\n<p>_____________<br \/>\n<strong><em>Michael Blaha<\/em><\/strong> is a partner at <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/modelsoftcorp.com');\"  href=\"http:\/\/modelsoftcorp.com\">Modelsoft Consulting Corporation<\/a>.<br \/>\n<em>Blaha received his doctorate from Washington University in St. Louis, Missouri in Chemical Engineering with his dissertation being about databases. Both his academic background and working experience involve engineering and computer science. He is an alumnus of the GE R&#038;D Center in Schenectady, New York, working there for eight years. Since 1993, Blaha has been a consultant and trainer in the areas of modeling, software architecture, database design, and reverse engineering. Blaha has authored six U.S. patents, four books, and many papers. Blaha is an editor for IEEE Computer as well as a member of the IEEE-CS publications board. He has also been active in the IEEE Working Conferences on Reverse Engineering.<\/em><\/p>\n<p><strong>Related Posts<\/strong><\/p>\n<p><strong>&#8211; <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.odbms.org\/blog\/2012\/08\/on-big-graph-data\/');\"  href=\"http:\/\/www.odbms.org\/blog\/2012\/08\/on-big-graph-data\/\">On Big Graph Data.  August 6, 2012<\/a><\/strong><\/p>\n<p> <strong>&#8211; <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.odbms.org\/blog\/2011\/06\/applying-graph-analysis-and-manipulation-to-data-stores\/');\"  href=\"http:\/\/www.odbms.org\/blog\/2011\/06\/applying-graph-analysis-and-manipulation-to-data-stores\/\">Applying Graph Analysis and Manipulation to Data Stores.  June 22, 2011<\/a><\/strong><\/p>\n<p><strong>Resources<\/strong><\/p>\n<p><strong>ODBMS.org Resources on Graphs and Data Stores<\/strong><br \/>\n<a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.odbms.org\/downloads.aspx#graphs_bp');\"  href=\"http:\/\/www.odbms.org\/downloads.aspx#graphs_bp\">Blog Posts<\/a> | <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.odbms.org\/downloads.aspx#graphs_fr');\"  href=\"http:\/\/www.odbms.org\/downloads.aspx#graphs_fr\">Free Software<\/a> | <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.odbms.org\/downloads.aspx#graphs_ap');\"  href=\"http:\/\/www.odbms.org\/downloads.aspx#graphs_ap\">Articles, Papers, Presentations<\/a>| <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/www.odbms.org\/downloads.aspx#graphs_tu');\"  href=\"http:\/\/www.odbms.org\/downloads.aspx#graphs_tu\">Tutorials, Lecture Notes<\/a><br \/>\n##<\/p>\n<p><strong>Follow ODBMS.org on Twitter: <a onclick=\"javascript:pageTracker._trackPageview('\/outgoing\/twitter.com\/odbmsorg');\"  href=\"https:\/\/twitter.com\/odbmsorg\">@odbmsorg<\/a><\/strong><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>&#8220;For traditional business applications, the schema is known in advance, so there is no need to use a graph database which has weaker enforcement of integrity. If instead, you&#8217;re dealing with at best a generic model to which it conforms, then a schema-oriented approach does not provide much. Instead a graph-oriented approach is more natural [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[139,233,376,439,499,549],"_links":{"self":[{"href":"https:\/\/www.odbms.org\/blog\/wp-json\/wp\/v2\/posts\/2047"}],"collection":[{"href":"https:\/\/www.odbms.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.odbms.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.odbms.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.odbms.org\/blog\/wp-json\/wp\/v2\/comments?post=2047"}],"version-history":[{"count":0,"href":"https:\/\/www.odbms.org\/blog\/wp-json\/wp\/v2\/posts\/2047\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.odbms.org\/blog\/wp-json\/wp\/v2\/media?parent=2047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.odbms.org\/blog\/wp-json\/wp\/v2\/categories?post=2047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.odbms.org\/blog\/wp-json\/wp\/v2\/tags?post=2047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}