<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Datomic Blog</title>
    <link>https://blog.datomic.com/</link>
    <atom:link href="https://www.datomic.com/feed.xml" rel="self" type="application/rss+xml" />
    <description>News from the Datomic team</description>
    <language>en-us</language>
    <pubDate>Mon, 16 Nov 2026 17:56:25 +0100</pubDate>
    <lastBuildDate>Mon, 16 Nov 2026 17:56:25 +0100</lastBuildDate>

    <item>
      <title>The Pull Newsletter (Nov 5, 2026)</title>
      <link>https://blog.datomic.com/2026/11/thepull.html</link>
      <pubDate>Thu, 5 Nov 2026 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2026/11/thepull.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Welcome back to the Pull! Here’s what the Datomic team and community has been up to over the past month.</p>
</div>

<div class="sect1">
<h2 id="_datomic_team_news">Datomic Team News</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://forum.datomic.com/t/datomic-1-0-7745-pro-now-available/2659">Datomic Pro 1.0.7745</a>, featuring several performance improvements and other fixes, is now available.</p>
</li>
<li>
<p>In case you missed it, we’ve launched a new version of <a href="https://www.datomic.com">datomic.com</a>. Let us know what you think!</p>
</li>
<li>
<p>We also have a brand-new <a href="https://www.datomic.com/playground.html">Datomic Query Playground</a>, a read-only interactive environment to try out Datomic queries and read APIs with Clojure. Take it out for a spin and send us any feedback.</p>
</li>
<li>
<p>At the 2026 Clojure Conj, Datomic Developer Success team member João Nascimento Mello led a Datomic Deep Dive workshop. If you weren’t able to attend, you can play along at home with the <a href="https://github.com/joaomello/datomic-lab">workshop lab materials</a>.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_community_projects">Community Projects</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Speaking of Clojure Conj 2026, speaker Wendy Randolph gave a talk there about "Modeling a Fabric Stash with Datomic," which shows "why Datomic’s attribute-based schema fits sparse, irregular data better than rigid relational tables."</p>
</div>
<div class="video-responsive">
  <iframe src="https://www.youtube.com/embed/0oFAEZRx3xk" title="Modeling a Fabric Stash with Datomic" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="paragraph">
<p>There’s a <a href="https://www.youtube.com/watch?v=tb00zvRvTN4">new video and demo from UnifyBio and the RCRF Pattern Data Commons</a>, which stores molecular and clinical data on rare cancers and is built around Datomic as its primary store and system of record. You can <a href="https://clojurians.slack.com/archives/C03RZMDSH/p1792340668948369">read more about the project</a> on the #datomic channel on Clojurians Slack.</p>
</div>
<div class="paragraph">
<p>Questions or suggestions? Reach out to the Datomic team and the rest of the community at the <a href="https://clojurians.slack.com/archives/C03RZMDSH">#datomic channel on Clojurians Slack</a>.</p>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>The Pull Newsletter (Oct 5, 2026)</title>
      <link>https://blog.datomic.com/2026/10/thepull.html</link>
      <pubDate>Mon, 5 Oct 2026 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2026/10/thepull.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Welcome to the first edition of <strong>The Pull</strong>, our new monthly Datomic newsletter rounding up projects and announcements from the Datomic community and the Datomic team.</p>
</div>

<div class="sect1">
<h2 id="_community_projects">Community Projects</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><strong>EACL v8 for Datomic Pro</strong> is now <a href="https://clojars.org/dev.eacl/eacl-datomic">available on Clojars</a> as RC1. EACL (Enterprise Access ControL) is a situated <a href="https://en.wikipedia.org/wiki/Relationship-based_access_control">ReBAC</a> authorization library inspired by <a href="https://authzed.com/spicedb">SpiceDB</a>, built in Clojure and backed by Datomic Pro, Datahike, Datalevin or DataScript, though <strong>Datomic Pro</strong> remains the primary backend. <a href="https://x.com/BraaiEngineer/status/2098139929033211926">Read the announcement</a> or <a href="http://demo.eacl.dev/">try the demo</a>.</p>
</li>
<li>
<p><a href="https://trydatomic.org/">Trydatomic.org</a>, an interactive website to learn how to query a Datomic database using Datalog, just got a content and design refresh.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_datomic_team_news">Datomic Team News</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p>In case you missed it: In April we released <strong>Datomic 1.0.7622</strong>, a big, feature-filled changelog with several performance improvements. It includes:</p>
<div class="ulist">
<ul>
<li>
<p><em>Feature</em>: <strong>Read-only connections</strong> to storage and backups</p>
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.datomic.com/operation/read-only.html">Read-only docs</a></p>
</li>
</ul>
</div>
</li>
<li>
<p><em>Feature</em>: <strong>rseek-datoms</strong>, reverse index iteration, a complement to seek-datoms</p>
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.datomic.com/clojure/index.html#datomic.api/rseek-datoms">rseek-datoms docs</a></p>
</li>
</ul>
</div>
</li>
<li>
<p><em>Performance</em>: <strong>Reduce log write amplification</strong> for systems with many transactions</p>
</li>
<li>
<p><em>New API</em>: <strong>list-backups</strong>, which lists the timepoints available in a backup repository</p>
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.datomic.com/clojure/index.html#datomic.api/list-backups">list-backups docs</a></p>
</li>
</ul>
</div>
</li>
<li>
<p><em>Performance</em>: <strong>Reduce CPU and memory</strong> required to calculate index metrics</p>
</li>
<li>
<p><em>Fix</em>: <strong>Regression</strong> introduced in 1.0.7556 which broke the ddb-local protocol</p>
</li>
</ul>
</div>
</li>
<li>
<p>Also earlier this year, Joe Lane, principal engineer at Nubank on the Datomic Core Dev team, gave a talk at the Unlocked Conference about <a href="https://www.youtube.com/watch?v=_-zPwiZH-R0">Immutability in Motion</a>, which explores how immutability and multi-tier caching power database performance at massive scale.</p>
</li>
<li>
<p>Recently Nubank engineers João Nascimento Mello and Mateus Oliveira, supported by engineers Gabrielle Cadurim and Carolina Silva, presented an online <a href="https://youtu.be/o6yOOrOyH7c?si=YQ7LWFxDBGnyaGb7">Day of Datomic workshop</a> in connection with the 2026 Clojure Conj, now available to watch on YouTube.</p>
</li>
<li>
<p>We&#8217;re hosting DatomicConf this December 11, 2026 in Durham, North Carolina. Registration and CFP are now open, so join us there. Details at <a href="https://conf.datomic.com/">conf.datomic.com</a>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Questions or suggestions? Reach out to the Datomic team and the rest of the community at the <a href="https://clojurians.slack.com/archives/C03RZMDSH">#datomic channel on Clojurians Slack</a>.</p>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Announcing DatomicConf 2026</title>
      <link>https://blog.datomic.com/2026/09/datomicconf.html</link>
      <pubDate>Wed, 2 Sep 2026 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2026/09/datomicconf.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Have you been thinking you need another conference to go to? Maybe in lovely Durham, North Carolina? We thought you might, so we made one. Later this year we&#8217;re hosting <strong>DatomicConf 2026</strong>.
</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/2026/09/datomicconf-wordmark.svg" alt="DatomicConf">
</div>
</div>
<div class="paragraph">
<p>Join us on <strong>Friday, December 11, 2026</strong>, in <strong>Durham, North Carolina</strong>, for a one-day, single-track conference dedicated to Datomic and the ideas and community around it. There will be news from the Datomic team, real-world Datomic use cases and opportunities to connect with other people who are building reliable, thoughtful systems.</p>
</div>
<div class="paragraph">
<p>Registration is <strong>free</strong> but <em>limited</em>, so if you&#8217;re planning on attending, <a href="https://forms.gle/extF42HTCQxfji7M6">register now</a>.</p>
</div>
<div class="paragraph">
<p>Our <a href="https://forms.gle/b3EWUvR6oFoLGVqW9">Call for Proposals</a> is also open and ready for your submissions.</p>
</div>
<div class="paragraph">
<p>If you&#8217;re interested in the possibility of a livestream, let us know at the <a href="https://forms.gle/mKaZdeAZg2bYyyJ5A">livestream interest form</a>.</p>
</div>
<div class="paragraph">
<p>All the details right now are at <a href="http://conf.datomic.com">conf.datomic.com</a>. We&#8217;ll soon share more information about hotels and visiting Durham. Check in on the <a href="https://clojurians.slack.com/archives/C03RZMDSH">#datomic channel</a> at the Clojurians Slack for updates or reach out to us at <a href="mailto:conf@datomic.com">conf@datomic.com</a> with any questions.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic at Clojure/Conj 2025</title>
      <link>https://blog.datomic.com/2026/01/conj2025.html</link>
      <pubDate>Wed, 21 Jan 2026 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2026/01/conj2025.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Happy belated new year! The Datomic team was among the six hundred participants at <a href="https://www.2025.clojure-conj.org/">Clojure/Conj 2025</a>. Here are some highlights.</p>
</div>
<div class="sect3">
<h4 id="_lessons_from_production">Lessons from Production</h4>
<div class="paragraph">
<p><a href="https://www.youtube.com/watch?v=gJ9UZlr6C6M">A Decade on Datomic</a> was full of lessons from Davis Shepherd and Jonathan Indig’s experience at Netflix. This is a technical talk with plenty of detail on how to leverage the semantics of a <a href="https://www.youtube.com/watch?v=Cym4TZwTCNU">"deconstructed" database</a> to design solutions for distributed systems challenges. We’ve put together a <a href="https://github.com/daveliepmann/talk-transcripts/blob/master/Shepherd_Davis_and_Indig_Jonathan_(Netflix)/ADecadeOnDatomic.md">transcript</a> for those who prefer a written version.</p>
</div>
<div class="paragraph">
<p>Tim Pote took us onto the warehouse floor in <a href="https://www.youtube.com/watch?v=NV02r1Y1B-8">Forklifts, Facts, and Functions</a> (<a href="https://github.com/daveliepmann/talk-transcripts/blob/master/Pote_Tim/ForkliftsFactsAndFunctions.md">transcript</a>). He illustrated how Datomic’s flexible schema and queryable history gave him the leverage to solve bugs simply and easily.</p>
</div>
<div class="paragraph">
<p>Darlei Soares and João Nascimento showed how they used Datomic to model Nubank microservices in <a href="https://www.youtube.com/watch?v=1vBm9XvS5QI">Immutable Knowledge Databases</a> (<a href="https://github.com/daveliepmann/talk-transcripts/blob/master/Soares_Darlei_and_Nascimento_Jo%C3%A3o/ImmutableKnowledgeDatabases.md">transcript</a>), revealing dependency patterns, risks and opportunities.</p>
</div>
</div>
<div class="sect3">
<h4 id="_amazing_day_of_datomic">Amazing Day of Datomic</h4>
<div class="paragraph">
<p>Our hands-on workshop is back. Based on Stuart Halloway’s original <a href="https://docs.datomic.com/resources/day-of-datomic.html">Day of Datomic</a>, the event was led by Nubank engineers Hanna Figueiredo and Carol Silva.</p>
</div>
<div class="paragraph">
<p>Our priority for the session was to incorporate the latest features and architectural insights. Feedback was overwhelmingly positive, with 100% of participants reporting improved mastery, specifically praising the combination of architectural “deep dives” and practical challenges. We appreciate everyone who took part and made it so interactive. The workshop remains one of our favorite ways to help developers gain a solid base of understanding Datomic’s unique power.</p>
</div>
</div>
<div class="sect3">
<h4 id="_fresh_datomic_tools">Fresh Datomic Tools</h4>
<div class="paragraph">
<p>Dustin Getz’s tour of <a href="https://www.youtube.com/watch?v=dmucZkE5gd0">A Datomic entity browser for prod</a> (<a href="https://github.com/daveliepmann/talk-transcripts/blob/master/Getz_Dustin/ADatomicEntityBrowserForProd.md">transcript</a>) was electrifying. The tool is part programmable spreadsheet and part visual graph explorer, with features like query monitoring and a powerful query DSL to make a smooth developer experience. We’re eager to see where this power will be applied.</p>
</div>
</div>
<div class="sect3">
<h4 id="_datomic_in_computational_biology">Datomic in Computational biology</h4>
<div class="paragraph">
<p>Benjamin Kamphaus’s <a href="https://www.youtube.com/watch?v=HU-uwSUZETw">Power Tools for Translational Data Science</a> (<a href="https://github.com/daveliepmann/talk-transcripts/blob/master/Kamphaus_Ben/UnifyBioPowerToolsForTranslationalDataScience.md">transcript</a>) was a more philosophical talk. It weaves historical linguistics, computational phylogenetics, constraint satisfaction, and the biology of rare cancers into a parable on why it matters how we build our tools.</p>
</div>
<div class="paragraph">
<p>It builds on his prior talks about his data science toolkit, <a href="https://www.youtube.com/watch?v=ulhr_50bevk">Clojure Where it Counts: Tidying Data Science Workflows</a> (with Pier Federico) and <a href="https://www.youtube.com/watch?v=vwZxHVcfwuw">Building a Unified Cancer Immunotherapy Data Library</a> (with Lacey Kitch), both of which dive more into the technical advantages that Clojure and Datomic provide.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="datomic-at-conj2025.jpg" alt="Some Datomic team members at Conj">
</div>
</div>
<div class="paragraph">
<p>Thanks to the organizers, speakers, and everyone who made the Conj such a vibrant time. We hope to see you there next year!</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>The Amazing Day of Datomic!</title>
      <link>https://blog.datomic.com/2024/09/Amazing-Day-of-Datomic.html</link>
      <pubDate>Fri, 13 Sep 2024 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2024/09/Amazing-Day-of-Datomic.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Join us for The Amazing Day of Datomic on Wed Oct 23, 1-5 pm at <a href="https://2024.clojure-conj.org">Clojure Conj 2024</a>. Amazing Day of Datomic is a comprehensive training program inspired by Stuart Halloway’s original “<a href="https://docs.datomic.com/resources/day-of-datomic.html">Day of Datomic</a>.” This updated version includes new features and insights, designed to provide you with a solid grasp of Datomic, from basic concepts to intermediate knowledge.</p>
</div>
<div class="ulist">
<div class="title">What You’ll Learn:</div>
<ul>
<li>
<p>Fundamentals Overview</p>
</li>
<li>
<p>Effective use of Datomic</p>
</li>
<li>
<p>Understanding Datomic operations</p>
</li>
<li>
<p>Troubleshooting techniques</p>
</li>
<li>
<p>And much more!</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Don’t miss this opportunity to enhance your skills and knowledge with the latest updates in Datomic. <a href="https://ti.to/nubank/clojureconj-2024">Sign up today</a>.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Jepsen Tests Datomic</title>
      <link>https://blog.datomic.com/2024/05/Jepsen-tests-Datomic.html</link>
      <pubDate>Wed, 15 May 2024 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2024/05/Jepsen-tests-Datomic.html</guid>
      	<description>
        <![CDATA[
	<div class="sect1">
<h2 id="_what_is_datomic">What is Datomic?</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="https://docs.datomic.com/datomic-overview.html">Datomic</a> is a general purpose database system designed for data-of-record applications. A Datomic database is a set of immutable atomic facts called <a href="https://docs.datomic.com/glossary.html#datom">datoms</a>. Datomic transactions add datoms, never updating or removing them, so you have a complete audit trail for data and the ability to query “as of” points in time. Datomic transactions are serialized in a total order, providing strong ACID guarantees.</p>
</div>
<div class="paragraph">
<p>Datomic has a powerful and flexible information model. Each Datomic database declares an attribute-level schema, and any entity can possess any attribute. You can query your data with datalog (a logic-based query) and navigate arbitrary hierarchies with pull. Datomic’s indexes automatically support many access patterns common in SQL, column, K/V, hierarchical, and graph databases.</p>
</div>
<div class="paragraph">
<p>Datomic is developed by Nubank, one of the world’s largest digital financial services platforms, serving over 100 million customers across Brazil, Mexico, and Colombia. At Nubank we use Datomic for almost all of our suite of products resulting in an average of 2.5 billion Datomic transactions being processed each day!</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_what_is_jepsen">What is Jepsen?</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="https://jepsen.io/">Jepsen</a> is a small consultancy focused on distributed systems safety. They write public reports, maintain open-source tooling, and offer training courses to make databases, queues, and other systems safer. Jepsen works with vendors like Nubank to evaluate their documentation and system behavior under a variety of failure modes, helps those vendors identify and fix bugs and documentation errors, and writes an analysis presenting their findings and recommendations for both vendors and users.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_jepsen_analysis_outcome">Jepsen Analysis Outcome</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Today, Jepsen released their analysis of Datomic’s <a href="https://jepsen.io/analyses/datomic-pro-1.0.7075">safety and correctness</a>.</p>
</div>

<div class="paragraph">
<p>Datomic aced the inter-transaction test and then some. Jepsen concluded:</p>
</div>
<div class="quoteblock">
<blockquote>
<div class="paragraph">
<p>We found no behavior which violated Datomic’s core safety claims. Transactions appeared to execute as if they had been applied in
a total order, and that order was consistent with the local order of operations on each peer. Histories restricted to just those
transactions performing writes, and histories in which reads used <code>(d/sync conn)</code> to obtain a current copy of the database, were
consistent with real-time order.</p>
</div>
<div class="paragraph">
<p>…</p>
</div>
<div class="paragraph">
<p>Indeed, we believe Datomic’s inter-transaction safety properties are stronger than promised.</p>
</div>
</blockquote>
</div>
<div class="paragraph">
<p>Based on these findings, we decided to <a href="https://docs.datomic.com/transactions/acid.html">strengthen and clarify our documentation about ACID properties</a>.</p>
</div>
<div class="paragraph">
<p>Jepsen’s intra-transaction tests also confirmed Datomic’s semantics. These tests required a great deal of explanation in the report. Most databases and formalisms for serializability provide sequential execution semantics within a transaction. Datomic applies most elements of a transaction in a semantically parallel manner. As a result, we updated our docs to better explain <a href="https://docs.datomic.com/transactions/transactions.html">Datomic’s transactions</a>, <a href="https://docs.datomic.com/tech-notes/composing-transactions-by-example.html">how they are composed</a>, and <a href="https://docs.datomic.com/tech-notes/comparison-with-updating-transactions.html">how they compare to other systems</a>.</p>
</div>
<div class="paragraph">
<p>Jepsen now tests Datomic in our CI system!</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Our partnership with Jepsen validated that Datomic is safe under a wide variety of circumstances, motivated valuable documentation improvements, and introduced a new battery of correctness tests that is now being used in our CI suite to continually ensure Datomic maintains the same high level of safety as the product evolves.</p>
</div>
<div class="paragraph">
<p>Our <a href="https://building.nubank.com.br">Building Nubank</a> blog has more content like this, dedicated to cutting-edge technologies!</p>
</div>
<div class="paragraph">
<p>Please check out <a href="https://international.nubank.com.br/careers/">Careers at Nu</a> if you are interested in joining our team!</p>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Local is Released</title>
      <link>https://blog.datomic.com/2023/08/datomic-local-is-released.html</link>
      <pubDate>Wed, 16 Aug 2023 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2023/08/datomic-local-is-released.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>The Datomic team is excited to announce the launch of <a href="https://docs.datomic.com/cloud/datomic-local.html">Datomic Local</a> under the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">Apache License 2.0</a>. Datomic Local is a library that is both embeddable and redistributable. It is a lightweight version of Datomic, designed to be easily embedded within applications and freely redistributed. Datomic Local supports the Client API, making it an excellent choice for small single-process applications and for testing systems that are based on the Datomic Client API.</p>
</div>
<div class="sect2">
<h3 id="_what_is_new">What is new?</h3>
<div class="paragraph">
<p>Datomic Local is a lightweight version of Datomic backed by local storage that supports the <a href="https://docs.datomic.com/cloud/client/client-api.html">Client API</a>. The Datomic Local and supporting binaries are released under the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">Apache License 2.0</a> license.</p>
</div>
</div>
<div class="sect2">
<h3 id="_how_to_get_it">How to get it</h3>
<div class="paragraph">
<p>Datomic Local is available on <a href="https://central.sonatype.com/artifact/com.datomic/local/1.0.267">Maven Central</a>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_use_cases">Use cases</h3>
<div class="paragraph">
<p>The Datomic Local version of Datomic is indicated for:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>People who want to write libraries that depend on Datomic</p>
</li>
<li>
<p>People who want an embedded DB</p>
</li>
<li>
<p>Cloud users who want to dev locally</p>
</li>
<li>
<p>People who already use dev-local</p>
</li>
</ul>
</div>
</div>
<div class="sect1">
<h2 id="_faq">FAQ</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_what_is_datomic_local">What is Datomic Local?</h3>
<div class="paragraph">
<p>Datomic Local is a lightweight version of Datomic backed by local storage which supports the Client API.</p>
</div>
</div>
<div class="sect2">
<h3 id="_what_changed">What changed?</h3>
<div class="paragraph">
<p>Datomic Local is a library, embeddable, and redistributable. Datomic Local replaces dev-local.</p>
</div>
</div>
<div class="sect2">
<h3 id="_how_to_get_datomic_local">How to get Datomic Local?</h3>
<div class="paragraph">
<p>Datomic Local is available on <a href="https://central.sonatype.com/artifact/com.datomic/local/1.0.267">Maven Central</a>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_what_changes_in_terms_of_licensing">What changes in terms of licensing?</h3>
<div class="paragraph">
<p>The Datomic Local binary is available under the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0 License</a>, which means that it is possible to redistribute it.</p>
</div>
</div>
<div class="sect2">
<h3 id="_for_whom_is_datomic_local_recommended">For whom is Datomic Local recommended?</h3>
<div class="ulist">
<ul>
<li>
<p>People who want to write libraries that depend on Datomic</p>
</li>
<li>
<p>People who want an embedded DB</p>
</li>
<li>
<p>Cloud users who want to dev locally</p>
</li>
<li>
<p>People who already use dev-local</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_what_happened_to_datomic_free">What happened to Datomic Free?</h3>
<div class="paragraph">
<p>If you are used to using Datomic Free, use <a href="https://www.datomic.com/">Datomic Pro</a>. If you want a redistributable, embeddable Datomic, use Datomic Local.</p>
</div>
</div>
<div class="sect2">
<h3 id="_what_is_the_difference_between_datomic_cloud_datomic_local_and_datomic_pro">What is the difference between Datomic Cloud, Datomic Local, and Datomic Pro?</h3>
<div class="paragraph">
<p><a href="https://docs.datomic.com/cloud/index.html"><strong>Datomic Cloud</strong></a> is tightly integrated with AWS. It supports only client access. Datomic Cloud has ions, which allows users to run entire applications on Datomic, with reproducible deployment, elastic autoscaling, and integration via AWS Lambda events and AWS API Gateway.</p>
</div>
<div class="paragraph">
<p><a href="https://docs.datomic.com/pro/overview/introduction.html"><strong>Datomic Pro</strong></a> is a distributed database designed to enable scalable, flexible applications running on-premises or in the cloud. It is fully designed for use against multiple storages in large-scale, multi-user systems.</p>
</div>
<div class="paragraph">
<p><a href="https://docs.datomic.com/cloud/datomic-local.html"><strong>Datomic Local</strong></a> is a lightweight version of Datomic that is embeddable, redistributable, and supports the Client API. It is well suited for single-process applications and for testing Client API-based Datomic systems.</p>
</div>
</div>
<div class="sect2">
<h3 id="_is_datomic_local_open_source">Is Datomic Local open source?</h3>
<div class="paragraph">
<p>No. The <em>binaries</em> are Apache 2.0, as with other versions of Datomic.</p>
</div>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Cloud is Free</title>
      <link>https://blog.datomic.com/2023/06/datomic-cloud-is-free.html</link>
      <pubDate>Fri, 16 Jun 2023 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2023/06/datomic-cloud-is-free.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Nubank is excited to announce today that Datomic Cloud is also now available free of licensing fees, and the Datomic binaries are being released under the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0</a> license.
Starting with this version, <a href="https://docs.datomic.com/cloud">Datomic Cloud</a> is now easier to get. To set up Datomic Cloud, check the instructions on <a href="https://docs.datomic.com/cloud/getting-started/getting-started.html">how to get started</a>.
We aim to make Datomic even more useful to more people in more situations. We are looking forward to expanding Datomic and Clojure worldwide!</p>
</div>
<div class="sect1">
<h2 id="_faq">FAQ</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_whats_changing_for_customers">What&#8217;s changing for customers?</h3>
<div class="paragraph">
<p>Moving forward, we are making the software <a href="https://docs.datomic.com/cloud/releases.html">easily available to everyone</a>, at no cost. As of version <a href="https://docs.datomic.com/cloud/changes.html#995-9204">995-9204</a> there will no longer be licensing fees associated with your use of Datomic Cloud.</p>
</div>
<div class="paragraph">
<p>All current agreements and support are continued in full effect. We will continue to offer paid enterprise support.</p>
</div>
<div class="paragraph">
<p>If you are interested in continuing support, and or leveraging the new licensing <a href="mailto:support@cognitect.com">call us</a>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_what_if_im_on_an_older_version_of_datomic_cloud">What if I&#8217;m on an older version of Datomic Cloud?</h3>
<div class="paragraph">
<p>Customers on versions of Datomic Cloud earlier than <a href="https://docs.datomic.com/cloud/changes.html#995-9204">995-9204</a> may continue to be charged fees associated with Datomic Cloud until they upgrade.</p>
</div>
</div>
<div class="sect2">
<h3 id="_why_did_you_choose_the_apache_2_0_license">Why did you choose the Apache 2.0 license?</h3>
<div class="paragraph">
<p>We want to make Datomic more useful to more people in more situations. The <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0 license</a> provides benefits to Datomic users in the areas of copyright, patent, redistribution, and more&#8201;&#8212;&#8201;just as it does for countless other projects.</p>
</div>
</div>
<div class="sect2">
<h3 id="_is_it_open_source">Is it Open Source?</h3>
<div class="paragraph">
<p>No. Datomic binaries are provided under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2</a> license which grants all the same rights to a work delivered in object form.</p>
</div>
<div class="paragraph">
<p>Datomic will continue to be developed at Nubank, where it is a critical piece of our infrastructure.</p>
</div>
</div>
<div class="sect2">
<h3 id="_will_pro_support_2_day_sla_business_hour_be_provided">Will Pro support (2 day SLA business hour) be provided?</h3>
<div class="paragraph">
<p>Yes, through the duration of your current license term. Moving forward, <a href="https://www.datomic.com/contact.html">contact us</a> if you are interested in an <a href="https://www.datomic.com/get-datomic.html">Enterprise Support</a> agreement.</p>
</div>
</div>
<div class="sect2">
<h3 id="_where_can_i_find_out_more">Where can I find out more?</h3>
<div class="ulist">
<ul>
<li>
<p><a href="https://www.datomic.com">www.datomic.com</a></p>
</li>
<li>
<p><a href="https://docs.datomic.com/cloud/">Datomic Cloud Documentation</a></p>
</li>
<li>
<p><a href="https://ask.datomic.com">ask.datomic</a></p>
</li>
<li>
<p><a href="https://forum.datomic.com">Datomic Forum</a></p>
</li>
<li>
<p><a href="https://clojurians.slack.com/archives/C03RZMDSH">#datomic in Clojurians Slack</a></p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_can_i_now_run_datomic_cloud_off_marketplace">Can I now run Datomic Cloud off marketplace?</h3>
<div class="paragraph">
<p>Yes.</p>
</div>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic is Free</title>
      <link>https://blog.datomic.com/2023/04/datomic-is-free.html</link>
      <pubDate>Thu, 27 Apr 2023 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2023/04/datomic-is-free.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Nubank is excited to announce today that we are making all editions of Datomic available free of licensing fees. The Datomic binaries are being released under the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0</a> license and will be readily available for direct download and use via Maven Central - no signup required. <a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa?ref=vdr_rf">Datomic Cloud</a> will be available on AWS Marketplace with no additional software cost.</p>
</div>

<div class="paragraph">
<p>We are doing this to make Datomic more useful to more people in more situations, and look forward to expanding the Datomic and Clojure community as a result.</p>
</div>
<div class="sect1">
<h2 id="_faq">FAQ</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_whats_changing_for_customers">What&#8217;s changing for customers?</h3>
<div class="paragraph">
<p>Moving forward, we are making the software <a href="https://docs.datomic.com/pro/releases.html">easily available to everyone</a>, at no cost.</p>
</div>
<div class="paragraph">
<p>All current agreements and support are continued in full effect. We will continue to offer paid enterprise support.</p>
</div>
<div class="paragraph">
<p>If you are interested in continuing support, and or leveraging the new licensing <a href="mailto:support@cognitect.com">call us</a>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_which_editions_of_datomic_will_be_free">Which editions of Datomic will be free?</h3>
<div class="paragraph">
<p>All of them. Datomic Pro is free of licensing fees, and now <a href="https://blog.datomic.com/2023/06/datomic-cloud-is-free.html">Datomic Cloud is available off AWS Marketplace with no associated license fees.</a></p>
</div>
</div>
<div class="sect2">
<h3 id="_why_did_you_choose_the_apache_2_0_license">Why did you choose the Apache 2.0 license?</h3>
<div class="paragraph">
<p>We want to make Datomic more useful to more people in more situations. The <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0 license</a> provides benefits to Datomic users in the areas of copyright, patent, redistribution, and more&#8201;&#8212;&#8201;just as it does for countless other projects.</p>
</div>
</div>
<div class="sect2">
<h3 id="_is_it_open_source">Is it Open Source?</h3>
<div class="paragraph">
<p>No. Datomic binaries are provided under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2</a> license which grants all the same rights to a work delivered in object form.</p>
</div>
<div class="paragraph">
<p>Datomic will continue to be developed at Nubank, where it is a critical piece of our infrastructure.</p>
</div>
</div>
<div class="sect2">
<h3 id="_will_pro_support_2_day_sla_business_hour_be_provided">Will Pro support (2 day SLA business hour) be provided?</h3>
<div class="paragraph">
<p>Yes, through the duration of your current license term. Moving forward, <a href="https://www.datomic.com/contact.html">contact us</a> if you are interested in an <a href="https://www.datomic.com/get-datomic.html">Enterprise Support</a> agreement.</p>
</div>
</div>
<div class="sect2">
<h3 id="_where_can_i_find_out_more">Where can I find out more?</h3>
<div class="ulist">
<ul>
<li>
<p><a href="https://www.datomic.com">www.datomic.com</a></p>
</li>
<li>
<p><a href="https://docs.datomic.com">Datomic Documentation</a></p>
</li>
<li>
<p><a href="https://ask.datomic.com">ask.datomic</a></p>
</li>
<li>
<p><a href="https://forum.datomic.com">Datomic Forum</a></p>
</li>
<li>
<p><a href="https://clojurians.slack.com/archives/C03RZMDSH">#datomic in Clojurians Slack</a></p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_can_i_now_run_datomic_cloud_off_marketplace">Can I now run Datomic Cloud off marketplace?</h3>
<div class="paragraph">
<p>Yes! See our <a href="https://blog.datomic.com/2023/06/datomic-cloud-is-free.html">Datomic Cloud is Free post</a></p>
</div>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Implicit Partitions</title>
      <link>https://blog.datomic.com/2023/04/implicit-partitions.html</link>
      <pubDate>Thu, 20 Apr 2023 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2023/04/implicit-partitions.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><strong>Datomic On-Prem</strong> is now called <strong>Datomic Pro</strong>. This post uses the original name.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>If you have an application that is struggling with performance, it might be due to poor data locality, the physical
distribution of relevant information. A query that is searching for sparsely distributed data will find few results per
storage read. Conversely, queries can efficiently slurp relevant data when it is densely colocated. Datomic&#8217;s partitions
allow applications to group entities together and gain control over locality. Entities that share a partition will
be colocated in the E-leading indexes, EAVT and AEVT. Because each partition requires a name and installation prior
to its use, it can become cumbersome to build schemes that use many partitions.</p>
</div>
<div class="paragraph">
<p>Today&#8217;s release of Datomic On-Prem includes a new feature: <a href="https://docs.datomic.com/transactions/partitions.html#implicit-partitions">Implicit Partitions</a>. These partitions are identified by an
integer, and they are usable without an installation step. There are 524288 (2^19) implicit partitions in each Datomic
database, and these facilitate the use of algorithmic partition assignment strategies, e.g. deterministically assigning
each customer to a particular partition, or assigning time-windowed data to different partitions.</p>
</div>
<div class="paragraph">
<p>Applications can transact entities into implicit partitions by passing one to d/tempid:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/transact conn [{:db/id (d/tempid (d/implicit-part 55))
                   :movie/title "The Great Gatsby"}])</code></pre>
</div>
</div>
<div class="paragraph">
<p>We are also introducing two new transaction data directives that facilitate partition assignment. To request put a new
entity into a particular partition, you can include its tempid in the :db/force-partition map. This can appear anywhere
in a transaction map form. Here is the same transaction using this directive with a string tempid:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/transact conn [{:db/id "movie"
                   :movie/title "The Great Gatsby"
                   :db/force-partition {"movie" (d/implicit-part 55)}}])</code></pre>
</div>
</div>
<div class="paragraph">
<p>The :db/match-partition directive says that an entity should have the same partition as another entity. Here, both items
will be in the same partition as its order, which is in implicit partition 15555:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/transact conn
            [{:db/id    "order"
              :order/id 123
              :order/items ["item1" "item2"]}

             {:db/id     "item1"
              :item/name "cereal"
              :item/sku  "A150"}

             {:db/id     "item2"
              :item/name "milk"
              :item/sku  "T770"}

             {:db/force-partition {"order" (d/implicit-part 15555)}
              :db/match-partition {"item1" "order"
                                   "item2" "order"}}])</code></pre>
</div>
</div>
<div class="paragraph">
<p>To learn more about implicit partitions, read the documentation for <a href="https://docs.datomic.com/transactions/partitions.html#implicit-partitions">Implicit Partitions</a> and <a href="https://docs.datomic.com/transactions/partitions.html#partition-assignment">Controlling Partition Assignment</a>, and the API documentation for <a href="https://docs.datomic.com/clojure/index.html">Datomic On-Prem</a>.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Query Stats</title>
      <link>https://blog.datomic.com/2023/01/Query-Stats.html</link>
      <pubDate>Wed, 25 Jan 2023 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2023/01/Query-Stats.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><strong>Datomic On-Prem</strong> is now called <strong>Datomic Pro</strong>. This post uses the original name.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Today&#8217;s release of Datomic On-Prem, and coming soon in Cloud, includes a new feature: query-stats.</p>
</div>
<div class="paragraph">
<p>query-stats is a new feature that gives users visibility into the decisions made by the query engine while it processed your query.</p>
</div>
<div class="paragraph">
<p>Datomic users can leverage the information returned by query-stats to find the optimal clause ordering for a query as well as gain visibility into various query components including query clauses, query rules, and query expressions.</p>
</div>
<div class="paragraph">
<p>For example, given the following query:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">{:find  [(count ?artist-name)]
 :where [[?release :release/name ?release-name]
         [?release :release/artists ?artist]
         [?artist :artist/name ?artist-name]]}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The following query-stats are returned:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">{:ret         [[4587]],
 :query-stats {:query  {:find  [(count ?artist-name)],
                        :where [[?release :release/name ?release-name]
                                [?release :release/artists ?artist]
                                [?artist :artist/name ?artist-name]]},
               :phases [{:sched   (([?release :release/name ?release-name]
                                    [?release :release/artists ?artist]
                                    [?artist :artist/name ?artist-name])),
                         :clauses [{:clause [?release :release/name ?release-name], :rows-in 0, :rows-out 11434, :binds-in (), :binds-out [?release], :expansion 11434, :warnings {:unbound-vars #{?release ?release-name}}}
                                   {:clause [?release :release/artists ?artist], :rows-in 11434, :rows-out 4600, :binds-in [?release], :binds-out [?artist]}
                                   {:clause [?artist :artist/name ?artist-name], :rows-in 4600, :rows-out 4587, :binds-in [?artist], :binds-out [?artist-name]}]}]}}</code></pre>
</div>
</div>
<div class="paragraph">
<p>This output can be more easily interpreted using REBL:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="40473ee8-8ba1-480f-92ed-28af07fe858f.png" alt="REBL table view of the query&#8217;s :clauses — one row per clause, with columns :rows-in, :rows-out, :binds-in, :binds-out, :expansion, and :warnings; the first clause carries an unbound-vars warning.">
</div>
</div>
<div class="paragraph">
<p>To learn more about query-stats and other enhancements:</p>
</div>
<div class="paragraph">
<p>Read the release announcement for <a href="https://forum.datomic.com/t/datomic-1-0-6610-now-available/2176">Datomic On-Prem</a>.</p>
</div>
<div class="paragraph">
<p>Read the API documentation for <a href="https://docs.datomic.com/on-prem/api/query-stats.html">Datomic On-Prem</a>.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Cloud 884-9095: New tiers and internet access</title>
      <link>https://blog.datomic.com/2021/07/Datomic-Cloud-884-9095-New-tiers-and-internet-access.html</link>
      <pubDate>Tue, 13 Jul 2021 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2021/07/Datomic-Cloud-884-9095-New-tiers-and-internet-access.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Datomic Cloud 884-9095 is a major new release offering more instance
options, lower pricing, API Gateway automation for ions and clients,
and more.</p>
</div>

<div class="sect1">
<h2 id="_more_instance_options">More instance options</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Datomic now provides a
<a href="https://docs.datomic.com/whatis/configurations-and-pricing.html">wider variety of compute, memory, and monitoring choices</a>.
Basic compute instances start from t3.small and
step up to t3.2xlarge, letting you ramp up on capability and cost
linearly.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_lower_pricing_at_all_scales">Lower pricing at all scales</h2>
<div class="sectionbody">
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic is Free</a>. The pricing information here is outdated.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>All instances sizes now cost less to run. If you were running Solo before,
you can <a href="https://docs.datomic.com/changes.html#884-solo">now run the smallest production tier</a>,
including a load balancer, for what solo cost before. If you are running production,
your cost <a href="https://docs.datomic.com/changes.html#884-prod">will be lower at your current instance size</a>,
and you may be able to select a smaller instance size as well.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_new_automation_ion_web_applications">New automation ion web applications</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Datomic&#8217;s CloudFormation templates can
<a href="https://docs.datomic.com/operation/architecture.html#api-gateway">automatically setup both the VPC link and API Gateway</a>
needed to expose your web application (ion).</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_new_client_access_from_outside_the_vpc">New client access from outside the VPC</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Building on the new API Gateway automation, you can now elect to
<a href="https://docs.datomic.com/operation/architecture.html#api-gateway">access your Datomic cloud system via an automatically-configured API Gateway</a>,
obviating the need for an access gateway and SOCKS proxy.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_run_and_scale_analytics_anywhere">Run and scale analytics anywhere</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Datomic <a href="https://docs.datomic.com/operation/architecture.html#analytics">analytics support</a>
is now available via a
<a href="https://docs.datomic.com/analytics/analytics-configuring.html">Datomic connector for Trino</a>.
With this connector, you can run analytics anywhere that you
would like, e.g. a dev laptop or a cluster in EC2. You can also access
Trino features including clustering and federation.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_security_first">Security first</h2>
<div class="sectionbody">
<div class="paragraph">
<p>All of the new access points described above (web ions, client access,
and analytics) are
<a href="https://docs.datomic.com/operation/architecture.html#security">secured via TLS, and Datomic compute nodes continue to run in a private VPC</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_metrics_choices">Metrics choices</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Datomic metrics are now available
<a href="https://docs.datomic.com/operation/growing-your-system.html">in two tiers: basic or detailed</a>.
(You can also turn off metrics entirely.) These choices let
you minimize cost or maximize observability, independently for each
compute group.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_try_it">Try it</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If you are an existing Datomic Cloud user, this release significantly
simplifies operations. Before you upgrade, please read <a href="https://docs.datomic.com/changes.html#884-9095">the changelog</a>
carefully, so that you understand all the things you will no longer
need to do.</p>
</div>
<div class="paragraph">
<p>If you are new to Datomic Cloud, <a href="https://docs.datomic.com/getting-started/start-system.html">getting started</a> has never been easier.</p>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Knowledgebase</title>
      <link>https://blog.datomic.com/2020/10/datomic-knowledgebase.html</link>
      <pubDate>Thu, 22 Oct 2020 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2020/10/datomic-knowledgebase.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>The <a href="https://ask.datomic.com/">Datomic Knowledgebase</a> has been launched to provide a place to <a href="https://ask.datomic.com/index.php/ask">ask questions</a>, provide answers, discuss and make feature requests.

Datomic Knowledgebase represents our commitment to improve <a href="https://docs.datomic.com/on-prem/index.html">Datomic</a> and <a href="https://docs.datomic.com/cloud/index.html">Datomic Cloud</a>.  It will serve as a place where you can help us prioritize our efforts and help shape the future of Datomic.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Cognitect Joins Nubank!</title>
      <link>https://blog.datomic.com/2020/07/cognitect-joins-nubank.html</link>
      <pubDate>Thu, 23 Jul 2020 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2020/07/cognitect-joins-nubank.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>We are thrilled to announce that Cognitect is joining
the Nubank family of companies. This is the next step in a long
relationship, and opens new opportunities for Clojure and Datomic
worldwide. Please read the full story over on the
<a href="https://cognitect.com/blog/2020/07/23/Cognitect-Joins-Nubank">Cognitect Blog</a>.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Analytics (Preview)</title>
      <link>https://blog.datomic.com/2019/10/datomic-analytics-preview.html</link>
      <pubDate>Tue, 1 Oct 2019 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2019/10/datomic-analytics-preview.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><strong>Datomic On-Prem</strong> is now called <strong>Datomic Pro</strong>. This post uses the original name.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Today&#8217;s releases of <a href="https://docs.datomic.com/cloud/index.html">Datomic Cloud</a> and <a href="https://docs.datomic.com/on-prem/index.html">Datomic On-Prem</a> preview a major new feature: analytics support.</p>
</div>
<div class="paragraph">
<p>With analytics support, your data scientists, analysts, and operations people can directly access Datomic using the languages and tools they already know (e.g. SQL, Python, R, Tableau, Metabase, Superset and more), without you having to do any ETL.</p>
</div>

<div class="paragraph">
<p>The analytics metaschema specifies a mapping from Datomic entities and attributes to dynamic SQL tables and columns, as shown in the example below:</p>
</div>
<div class="imageblock">
<div class="content">
<a class="image" href="https://www.youtube.com/watch?v=jVKGYu0_OCA"><img src="/images/blog/-Ec0OoaOk1ss/XZNv6C9KuTI/AAAAAAAAAl0/kva0YdqvLQoT9DE1CP-59BiPG4HcS8x0ACLcBGAsYHQ/s1600/analyticsTables.png" alt="Analytics tables example"></a>
</div>
</div>
<div class="paragraph">
<p>In Cloud, the bastion server has been renamed to access gateway, as it now also supports analytics. Analytics support is automatic when you select an EC2 instance size that supports it, and costs nothing beyond the cost of the EC2 instance.</p>
</div>
<div class="paragraph">
<p>In On-Prem, analytics support is available via the <code>bin/presto</code> script in the distribution.</p>
</div>
<div class="paragraph">
<p>To learn more about the analytics preview:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Watch <a href="https://www.youtube.com/watch?v=jVKGYu0_OCA">the video</a>.</p>
</li>
<li>
<p>Read the <a href="https://docs.datomic.com/cloud/analytics/analytics-concepts.html">Cloud docs</a>.</p>
</li>
<li>
<p>Read the <a href="https://docs.datomic.com/on-prem/analytics/analytics-concepts.html">On-Prem docs</a>.</p>
</li>
</ul>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Tuples and Database Predicates</title>
      <link>https://blog.datomic.com/2019/06/tuples-and-database-predicates.html</link>
      <pubDate>Fri, 28 Jun 2019 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2019/06/tuples-and-database-predicates.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><strong>Datomic On-Prem</strong> is now called <strong>Datomic Pro</strong>. This post uses the original name.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Today&#8217;s releases of <a href="https://docs.datomic.com/cloud/index.html">Datomic Cloud</a> and <a href="https://docs.datomic.com/on-prem/index.html">Datomic On-Prem</a> include two major new features: tuples and database predicates.</p>
</div>
<div class="paragraph">
<p>Tuples are a new compound data type, small vectors as values. You can use tuples to create multi-attribute unique keys on domain entities. You can also use tuples to optimize queries that otherwise would have to join two or more high-population attributes.</p>
</div>

<div class="ulist">
<ul>
<li>
<p>If you declare a <em>composite</em> tuple, Datomic will automatically populate the tuple from existing attributes.</p>
</li>
<li>
<p>You can also define your own homogeneous or heterogeneous tuple types that you populate as you see fit.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Database predicates are functions and attribute lists that constrain the values accepted by transactions.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Attribute predicates are declared in schema and constrain the values taken on by a single attribute, in all contexts. For example, you could limit a <code>test/grade</code> attribute to the range 0-100.</p>
</li>
<li>
<p>Entity specs comprise lists of required attributes and/or predicates of the entity and the post-transaction db. You can use entity specs to ensure properties across different attributes of an entity or even across entities. For example, you might enforce that a game player&#8217;s <code>score/lowest</code> must be less than or equal to their <code>score/highest</code>. You must explicitly call for entity specs in transactions in which you want them to apply.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>To learn more about tuples, database predicates, and other enhancements:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Read the release announcement for <a href="https://forum.datomic.com/t/datomic-cloud-480-8770/1042">Datomic Cloud 480-8770</a>.</p>
</li>
<li>
<p>Read the release announcement for <a href="https://forum.datomic.com/t/datomic-0-9-5927-now-available/1040">Datomic On-Prem 0.9.5927</a>.</p>
</li>
</ul>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Return Maps</title>
      <link>https://blog.datomic.com/2019/06/return-maps-for-datomic-cloud-clients.html</link>
      <pubDate>Tue, 18 Jun 2019 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2019/06/return-maps-for-datomic-cloud-clients.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p>Because <a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic Cloud is free</a>, it is no longer distributed via AWS Marketplace. Use CloudFormation instead; see <a href="https://docs.datomic.com/setup-cloud/cloud-setup.html">Datomic Cloud Setup</a>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Most <a href="https://datomic.com/">Datomic</a> queries return tuples, but sometimes you just want maps. <a href="https://forum.datomic.com/t/new-cloud-client-release-0-8-78/1024">Today&#8217;s release</a> of the Datomic Cloud client library adds return maps to Datomic datalog. For example, the following query uses the new <code><strong>:keys</strong></code> clause to request maps with <code><strong>:artist</strong></code> and <code><strong>:release</strong></code> keys:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">[:find ?artist-name ?release-name
 :keys artist release
 :where [?release :release/name ?release-name]
 [?release :release/artists ?artist]
 [?artist :artist/name ?artist-name]]</code></pre>
</div>
</div>

<div class="paragraph">
<p>Running against the <a href="https://github.com/Datomic/mbrainz-sample">mbrainz-sample</a> database, this query returns:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">#{{:artist "George Jones" :release "With Love"}
 {:artist "Shocking Blue" :release "Hello Darkness / Pickin' Tomatoes"}
 {:artist "Junipher Greene" :release "Friendship"}
 ...}</code></pre>
</div>
</div>
<div class="paragraph">
<p>To try return maps, you can</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Sign up for <a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa">Datomic Cloud on AWS Marketplace</a>.</p>
</li>
<li>
<p>Read the new <a href="https://docs.datomic.com/cloud/query/query-data-reference.html#return-maps">return maps docs</a>.</p>
</li>
</ul>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>HTTP Direct for Datomic Cloud</title>
      <link>https://blog.datomic.com/2019/05/http-direct-for-datomic-cloud.html</link>
      <pubDate>Thu, 23 May 2019 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2019/05/http-direct-for-datomic-cloud.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p><a href="https://www.datomic.com/">Datomic Cloud</a> is designed to be a <a href="https://docs.datomic.com/cloud/operation/architecture.html#applications">complete solution for Clojure application development</a> on AWS. In particular, you can implement web services as <a href="https://docs.datomic.com/cloud/ions/ions.html">Datomic ions</a> behind AWS API Gateway.</p>
</div>
<div class="paragraph">
<p>The latest release of Datomic Cloud adds HTTP Direct, which lets you connect an API Gateway endpoint directly to a <a href="https://docs.datomic.com/cloud/operation/architecture.html#production-topology">Production Topology Compute Group</a> as shown below:</p>
</div>

<div class="imageblock">
<div class="content">
<img src="/images/blog/-q5k81rwmfBc/XN281Kd8L9I/AAAAAAAAARI/CeONlx4EG-8PMViGZN5pM1lZlx6d6rD9QCLcBGAs/s1600/application-consumers.png" alt="HTTP Direct application consumers diagram">
</div>
</div>
<div class="paragraph">
<p>HTTP Direct provides better performance and simpler operation than AWS Lambda Proxy Integration. The latter option continues to be supported on the <a href="https://docs.datomic.com/cloud/operation/architecture.html#solo-topology">Solo Topology</a>, which does not include the Network Load Balancer required for HTTP Direct.</p>
</div>
<div class="paragraph">
<p>To try out HTTP Direct:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Get the <a href="https://docs.datomic.com/cloud/releases.html#current">latest release</a> of Datomic Cloud.</p>
</li>
<li>
<p>Work through the <a href="https://docs.datomic.com/cloud/livetutorial/http-direct.html">HTTP Direct Tutorial</a>.</p>
</li>
</ol>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Valcache for Datomic On-Prem</title>
      <link>https://blog.datomic.com/2018/10/valcache.html</link>
      <pubDate>Tue, 9 Oct 2018 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2018/10/valcache.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><strong>Datomic On-Prem</strong> is now called <strong>Datomic Pro</strong>. This post uses the original name.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Everything gets better when data moves closer to processing. <a href="https://www.datomic.com/">Datomic</a> can extensively cache its immutable data without concern for coordination or invalidation. With the 'valcache' feature in today&#8217;s Datomic On-Prem release you can use your local SSDs as large, durable per-process caches, on both transactors and peers. Valcache can improve performance, reduce the read load on storage and stay hot across process restarts.</p>
</div>

<div class="imageblock">
<div class="content">
<img src="/images/blog/-4sZwll9D3Mk/W7YOPYiShPI/AAAAAAAAAPY/SBlR07xnM9gIUQDZftjbFsVeG4uwp32DwCLcBGAs/s1600/valcache.png" alt="Valcache diagram">
</div>
</div>
<div class="paragraph">
<p>To get started with Valcache for Datomic On-Prem:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://my.datomic.com/login">Get the latest release</a> of Datomic.</p>
</li>
<li>
<p>Read the <a href="https://docs.datomic.com/operation/valcache.html">Valcache docs</a>.</p>
</li>
</ul>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Query Groups</title>
      <link>https://blog.datomic.com/2018/09/query-groups.html</link>
      <pubDate>Fri, 7 Sep 2018 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2018/09/query-groups.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p>Because <a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic Cloud is free</a>, it is no longer distributed via AWS Marketplace. Use CloudFormation instead; see <a href="https://docs.datomic.com/setup-cloud/cloud-setup.html">Datomic Cloud Setup</a>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>A Datomic system can grow to meet the needs of your applications with query groups.</p>
</div>
<div class="paragraph">
<p>Query groups provide one or more applications in a system with independent, elastically scalable query resources and working set caches. You can deploy different <a href="https://docs.datomic.com/cloud/ions/ions.html">Datomic Ion</a> applications to different query groups.</p>
</div>

<div class="paragraph">
<p>Query groups can host different application development stages, each running their own revision of an Ion application.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-aZsqutkmZaE/W5KQv0VXWxI/AAAAAAAAAOw/BeCePUbcdVMpp6vrGSmi5Caki6tKisavQCLcBGAs/s1600/multi-application.png" alt="Multi-application query groups diagram">
</div>
</div>
<div class="paragraph">
<p>To learn more about query groups, read the new <a href="https://docs.datomic.com/cloud/operation/growing-your-system.html">Growing Your System</a> documentation.</p>
</div>
<div class="paragraph">
<p><a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa?ref=vdr_rf">image::/images/blog/-RWCSBWdNFAI/W5KWNVJjBFI/AAAAAAAAAPE/91y92LJM1rUb_UDKji_XJFCtA8EyzYYqACLcBGAs/s400/aws-marketplace.png[Datomic Cloud on AWS Marketplace</a>]</p>
</div>
<div class="paragraph">
<p><a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa?ref=vdr_rf">Datomic Cloud on AWS Marketplace</a></p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Parameterizing Datomic Ion Applications</title>
      <link>https://blog.datomic.com/2018/08/ion-parameters.html</link>
      <pubDate>Wed, 15 Aug 2018 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2018/08/ion-parameters.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p>Because <a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic Cloud is free</a>, it is no longer distributed via AWS Marketplace. Use CloudFormation instead; see <a href="https://docs.datomic.com/setup-cloud/cloud-setup.html">Datomic Cloud Setup</a>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Today&#8217;s Datomic Cloud release provides an easy way to parameterize <a href="https://blog.datomic.com/2018/06/datomic-ions.html">ion applications</a>.</p>
</div>
<div class="sect2">
<h3 id="_rationale">Rationale</h3>
<div class="paragraph">
<p>At runtime, applications need access to configuration data such as the name of a Datomic database. There are several challenges to consider:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Configuration values have a lifecycle that is independent of application source code. They should not be hard-coded in the application, and should be managed separately from source code.</p>
</li>
<li>
<p>Applications need a way to obtain their configuration values at runtime.</p>
</li>
<li>
<p>Configuration values may be sensitive, and should not be stored or conveyed as plaintext.</p>
</li>
</ul>
</div>

<div class="paragraph">
<p>Parameters are a solution to these challenges.</p>
</div>
</div>
<div class="sect2">
<h3 id="_ion_parameters">Ion Parameters</h3>
<div class="paragraph">
<p>Before running your app, you store parameter values under hierarchical keys in <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html">AWS Systems Manager Parameter Store</a>. At runtime, your app uses our new APIs to form the keys and read the values. This provides:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>independent lifecycle for parameter values</p>
</li>
<li>
<p>encryption for sensitive data</p>
</li>
<li>
<p>granular IAM permissions</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_get_started">Get Started</h3>
<div class="paragraph">
<p>To get started using Datomic&#8217;s parameter support:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa">Sign up for Datomic</a> on the AWS Marketplace.</p>
</li>
<li>
<p>Learn more about ions from this <a href="https://www.youtube.com/watch?v=TbthtdBw93w">short video</a>.</p>
</li>
<li>
<p>Read the new <a href="https://docs.datomic.com/cloud/ions/ions-reference.html#parameters">Ion Parameters documentation</a>.</p>
</li>
</ul>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Cloud Monitoring and Ion Cast</title>
      <link>https://blog.datomic.com/2018/07/datomic-ion-cast.html</link>
      <pubDate>Wed, 11 Jul 2018 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2018/07/datomic-ion-cast.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p>Because <a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic Cloud is free</a>, it is no longer distributed via AWS Marketplace. Use CloudFormation instead; see <a href="https://docs.datomic.com/setup-cloud/cloud-setup.html">Datomic Cloud Setup</a>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The new datomic.ion.cast library lets your application produce monitoring data that are integrated with Datomic&#8217;s support for AWS CloudWatch.</p>
</div>

<div class="sect3">
<h4 id="_datomic_cloud_and_aws_cloudwatch">Datomic Cloud and AWS CloudWatch</h4>
<div class="paragraph">
<p>AWS CloudWatch provides a powerful set of tools for monitoring a software system running on AWS:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Collect and track <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html">CloudWatch Metrics</a>&#8201;&#8212;&#8201;variables that measure the behavior of your system.</p>
</li>
<li>
<p>Configure <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html">CloudWatch Alarms</a> to notify operations or take other automated steps when potential problems arise.</p>
</li>
<li>
<p>Monitor, store, and search <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html">CloudWatch Logs</a> across all your AWS resources.</p>
</li>
<li>
<p>Create <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html">CloudWatch Dashboards</a> that provide a single overview for monitoring your systems.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Datomic Cloud is fully integrated with all of these AWS monitoring tools. On the producing side, Datomic creates <a href="https://docs.datomic.com/cloud/operation/monitoring.html#metrics">metrics</a> and <a href="https://docs.datomic.com/cloud/operation/monitoring.html#logs">logs</a>; and on the consuming side, Datomic organizes metrics in custom <a href="https://docs.datomic.com/cloud/operation/monitoring.html#dashboards">dashboards</a> like this Production Dashboard:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-109XXHedhlY/WnOUIygZswI/AAAAAAAAAMc/6yCkVC4ykEQf8bh9uDjIOKonysv_gsL1gCPcBGAYYCw/s1600/production-dashboard.png" alt="Production Dashboard">
</div>
</div>
</div>
<div class="sect3">
<h4 id="_datomic_ion_cast">datomic.ion.cast</h4>
<div class="paragraph">
<p>With the introduction of <a href="https://docs.datomic.com/cloud/ions/ions.html">Datomic Ions</a>, your entire application can run on Datomic Cloud nodes. The <code><strong>datomic.ion.cast</strong></code> namespace lets Ion application code add your own monitoring data alongside the monitoring data already being produced by Datomic. Cast supports four categories of monitoring data:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>An event is an ordinary occurence that is of interest to an operator, such as start and stop events for a process or activity.</p>
</li>
<li>
<p>An alert is an extraordinary occurrence that requires operator intervention, such as the failure of some important process.</p>
</li>
<li>
<p>Dev is information of interest only to developers, e.g. fine-grained logging to troubleshoot a problem during development. Dev data can be much higher volume than events or alerts.</p>
</li>
<li>
<p>A metric is a numeric value in a named time series, such as the latency for an operation.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>To get started using ion.cast, you can</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa">sign up for Datomic</a> on the AWS Marketplace</p>
</li>
<li>
<p>learn about Datomic Ions in <a href="https://www.youtube.com/watch?v=TbthtdBw93w">this short video</a></p>
</li>
<li>
<p>read the new <a href="https://docs.datomic.com/cloud/ions/ions-monitoring.html">Monitoring Ions</a> documentation</p>
</li>
</ul>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Ions: Your App on Datomic Cloud</title>
      <link>https://blog.datomic.com/2018/06/datomic-ions.html</link>
      <pubDate>Wed, 6 Jun 2018 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2018/06/datomic-ions.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p>Because <a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic Cloud is free</a>, it is no longer distributed via AWS Marketplace. Use CloudFormation instead; see <a href="https://docs.datomic.com/setup-cloud/cloud-setup.html">Datomic Cloud Setup</a>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><strong>Datomic On-Prem</strong> is now called <strong>Datomic Pro</strong>. This post uses the original name.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Datomic Ions let you develop applications for the cloud by deploying your code to a running Datomic cluster. You can <strong>focus on your application logic</strong>, writing ordinary Clojure functions, and the ion tooling and infrastructure handles the deployment and execution details. You can leverage your code both inside Datomic transactions and queries, and from the world at large via built-in support for AWS Lambda.</p>
</div>

<div class="paragraph">
<p>With Datomic Ions you can:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Focus on your application</p>
</li>
<li>
<p>Leverage your Datomic Cloud cluster compute resources and data locality</p>
</li>
<li>
<p>Extend Datomic transactions and queries with your own logic</p>
</li>
<li>
<p>Connect to the broader AWS cloud via Lambda events</p>
</li>
<li>
<p>Service web consumers with API Gateway</p>
</li>
<li>
<p>Scale Datomic and your app together</p>
</li>
<li>
<p>Deliver on AWS with high agility</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>To learn more about ions, check out the <a href="https://docs.datomic.com/cloud/ions/ions.html">Datomic Cloud Ions documentation</a>.</p>
</div>
<div class="paragraph">
<p>For Datomic On-Prem, we have added <a href="https://docs.datomic.com/transactions/transaction-functions.html#deploying-classpath-fns">classpath functions</a> and auto-require support for transaction functions and <a href="https://docs.datomic.com/query/query-data-reference.html#calling-clojure-functions">query expressions</a>.</p>
</div>
<div class="paragraph">
<p><a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa?ref=vdr_rf">image::/images/blog/-RxcRgwasB3c/Wl0jyzGrOJI/AAAAAAAAAYI/i4KkQsM4BtUCkg3MwRME5ihyDNZ1DhvcwCLcBGAs/s1600/aws-marketplace-380x70.png[Datomic Cloud on the AWS Marketplace</a>]</p>
</div>
<div class="paragraph">
<p><a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa?ref=vdr_rf">Datomic Cloud on the AWS Marketplace</a></p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Important Security Update For free: and dev: Storage Protocols</title>
      <link>https://blog.datomic.com/2018/03/important-security-update.html</link>
      <pubDate>Thu, 29 Mar 2018 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2018/03/important-security-update.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><strong>Datomic On-Prem</strong> is now called <strong>Datomic Pro</strong>. This post uses the original name.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Release 0.9.5697 fixes two security vulnerabilities in Datomic On-Prem transactors running the free: or dev: storage protocol.
</p>
</div>
<div class="paragraph">
<p>For more information, see the <a href="https://forum.datomic.com/t/important-security-update-0-9-5697/379">release announcement</a>.</p>
</div>
<div class="paragraph">
<p>The Datomic team would like to thank Caio Vargas, Matheus Bernardes, and Nubank for reporting this issue.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Access Control in Datomic Cloud</title>
      <link>https://blog.datomic.com/2018/02/access-control-in-datomic-cloud.html</link>
      <pubDate>Mon, 19 Feb 2018 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2018/02/access-control-in-datomic-cloud.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>In this article, we will look at Datomic access control, covering</p>
</div>
<div class="ulist">
<ul>
<li>
<p>authentication and authorization</p>
</li>
<li>
<p>network-level access</p>
</li>
<li>
<p>how the bastion works</p>
</li>
<li>
<p>some example deployments</p>
</li>
</ul>
</div>

<div class="sect2">
<h3 id="_authentication_and_authorization">Authentication and Authorization</h3>
<div class="paragraph">
<p>Datomic integrates with AWS <a href="https://aws.amazon.com/iam">Identity and Access Management</a> (IAM) for authentication and authorization, via a technique that we&#8217;ll call S3 proxying. Here&#8217;s how it works:</p>
</div>
<div class="paragraph">
<p>Every Datomic permission has a hierarchical name. For example, read-only access to database <code>Jan</code> is named <code>access/dbs/db/Jan/read</code>.</p>
</div>
<div class="paragraph">
<p>Permission names have a 1-1 correspondence with keys in the Datomic <a href="https://docs.datomic.com/cloud/operation/architecture.html#storage-resources">system S3 bucket</a>.</p>
</div>
<div class="paragraph">
<p>The Datomic client signs requests using AWS&#8217;s <a href="https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html">Signature Version 4</a>. But instead of using your IAM credentials directly, the Datomic client uses your IAM credentials to retrieve a signing key from S3.</p>
</div>
<div class="paragraph">
<p>Thus, IAM read permissions of S3 paths act as proxies for Datomic permissions. As a result, you can use all of the ordinary IAM tools (roles, groups, users, policies, etc.) to authorize use of Datomic.</p>
</div>
<div class="paragraph">
<p>After decades of experience with racing to log into new servers to change the admin password, we think that this "secure by default" is pretty cool. But that is not the end of the story, as clients also must have network-level access to Datomic.</p>
</div>
</div>
<div class="sect2">
<h3 id="_network_level_access">Network-Level Access</h3>
<div class="paragraph">
<p>Datomic Cloud is designed to be accessed by applications running inside a VPC, and (unlike a service!) is never exposed to the Internet. You must make an explicit choice to access Datomic. You could:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>run an EC2 instance in the Datomic VPC and in the Datomic applications security group</p>
</li>
<li>
<p><a href="https://docs.aws.amazon.com/AmazonVPC/latest/PeeringGuide/Welcome.html">peer another VPC</a> with the Datomic VPC</p>
</li>
<li>
<p>configure a <a href="https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpn-connections.html">VPN Connection</a></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Each of these approaches has its place for application access, and I will say more about them in a future article. For easy access to Datomic from a developer&#8217;s laptop we offer the bastion.</p>
</div>
</div>
<div class="sect2">
<h3 id="_how_the_bastion_works">How the Bastion Works</h3>
<div class="paragraph">
<p>The <a href="https://docs.datomic.com/cloud/operation/bastion.html">bastion</a> is a dedicated machine with one job only: to enable developer access to Datomic. When you turn the bastion on, you get a barebones AWS Linux instance that does exactly one thing: forwards SSH traffic to your Datomic system.</p>
</div>
<div class="paragraph">
<p>To connect through the bastion:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>run the <a href="https://docs.datomic.com/cloud/getting-started/connecting.html#socks-proxy">Datomic socks proxy script</a> on your local machine</p>
</li>
<li>
<p>add a proxy port argument when <a href="https://docs.datomic.com/cloud/getting-started/connecting.html#use-datomic">creating a system client</a></p>
</li>
<li>
<p>the Datomic client sees the proxy port argument and connects to the socks proxy</p>
</li>
<li>
<p>the socks proxy forwards encrypted SSH traffic to the bastion</p>
</li>
<li>
<p>the bastion forwards Datomic client protocol traffic to Datomic</p>
</li>
</ol>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-T2tD9ClQURw/WoYOD0QyIVI/AAAAAAAAANI/NJv4Qoe0QYglfPhmrLtup8Du-Q1-oeZCwCLcBGAs/s1600/bastion-access.png" alt="Bastion access diagram">
</div>
</div>
<div class="paragraph">
<p>Access to the bastion is secured using the same IAM + S3 proxying technique used earlier for auth. The bastion has an auto-generated, ephemeral private key that is stored in S3 and secured by IAM.</p>
</div>
<div class="paragraph">
<p>The bastion is dynamic, and you can <a href="https://docs.datomic.com/cloud/operation/bastion.html#starting-and-stopping">turn it on or off</a> at any time. And the client support means that the bastion is entirely transparent to your code, which differs only in the argument used to create the client.</p>
</div>
</div>
<div class="sect2">
<h3 id="_a_concrete_example">A Concrete Example</h3>
<div class="paragraph">
<p>As a concrete example, here is how the <a href="https://twitter.com/datomic_team">Datomic team</a> configures access for some of our Datomic systems:</p>
</div>
<div class="paragraph">
<p>Our 'ci' system is dedicated to continuous integration, supporting several dozen Jenkins projects. The ci system contains no sensitive data, only canned and generated examples. The ci system runs the <a href="https://docs.datomic.com/cloud/operation/architecture.html#solo-topology">Solo Topology</a> with the bastion enabled to allow access by automated tests.</p>
</div>
<div class="paragraph">
<p>Our 'devdata' system contains non-sensitive data used by the development team (think departmental and sample apps). The devdata system runs the Solo Topology with the bastion enabled to allow access by developers.</p>
</div>
<div class="paragraph">
<p>Our 'applications' system supports applications and contains real-world data. The applications system is reachable only by deployed application code, and needs to be highly available. So the applications system uses the <a href="https://docs.datomic.com/cloud/operation/architecture.html#production-topology">Production Topology</a> with the bastion disabled, and also uses fine-grained IAM permissions to limit applications to the databases they need.</p>
</div>
</div>
<div class="sect2">
<h3 id="_conclusion">Conclusion</h3>
<div class="paragraph">
<p>Datomic is secure by default, integrating directly with AWS IAM and VPC capabilities. The bastion makes it easy for developers to get connected, so you can be up and transacting on a new system in minutes.</p>
</div>
<div class="paragraph">
<p>To learn more, check out</p>
</div>
<div class="ulist">
<ul>
<li>
<p>my <a href="https://www.datomic.com/videos.html">videos</a> of setting up a Datomic Cloud system</p>
</li>
<li>
<p>the <a href="https://docs.datomic.com/cloud/operation/access-control.html">access control</a> docs</p>
</li>
<li>
<p>the <a href="https://docs.datomic.com/cloud/operation/bastion.html">bastion</a> docs</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Or just <a href="https://docs.datomic.com/cloud/setting-up.html">dive in</a> and get started.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>High Availability in Datomic Cloud</title>
      <link>https://blog.datomic.com/2018/01/high-availability-in-datomic-cloud.html</link>
      <pubDate>Wed, 24 Jan 2018 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2018/01/high-availability-in-datomic-cloud.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><strong>Datomic On-Prem</strong> is now called <strong>Datomic Pro</strong>. This post uses the original name.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Based on my rigorous polling, these are the top five questions people have about HA in <a href="https://www.datomic.com/">Datomic Cloud</a>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>How does it work?</p>
</li>
<li>
<p>What do I have to do?</p>
</li>
<li>
<p>Hey wait a minute! What about serializability?</p>
</li>
<li>
<p>Is AWS cool?</p>
</li>
<li>
<p>So what else have you got?</p>
</li>
</ul>
</div>
<div class="sect2">
<h3 id="_how_does_it_work">How Does It Work?</h3>
<div class="paragraph">
<p>In the <a href="https://docs.datomic.com/cloud/operation/architecture.html#production-topology">Production Topology</a>, Datomic cluster nodes sit behind an Application Load Balancer (ALB). As any node can handle any request, there is no single point of failure. The starting cluster size of two ensures that nodes remain available in the face of a single node failure. By increasing the cluster size beyond two, you both enhance availability and increase the number of queries the system can handle. An AutoScaling Group (ASG) monitors nodes and automatically replaces nodes that fail to health check.</p>
</div>

<div class="imageblock">
<div class="content">
<img src="/images/blog/-tQ_iRSp9o74/WmjJUy8xmkI/AAAAAAAAAL0/PyyXXxUE7fMFVQfqLkMoOwpGdTUfqqe5wCLcBGAs/s1600/query-144-100.png" alt="Query diagram">
</div>
</div>
</div>
<div class="sect2">
<h3 id="_what_do_i_have_to_do">What Do I Have To Do?</h3>
<div class="paragraph">
<p>Nothing. HA is automatic.</p>
</div>
</div>
<div class="sect2">
<h3 id="_hey_wait_a_minute_what_about_serializability">Hey Wait a Minute! What About Serializability?</h3>
<div class="paragraph">
<p>We <a href="https://www.datomic.com/">really like transactions</a>:</p>
</div>
<div class="quoteblock">
<blockquote>
<div class="paragraph">
<p>Datomic is always transactional, fully serialized, and consistent in both the ACID and CAP senses. Don&#8217;t waste your life writing code to compensate for partial failures and subtle concurrency bugs when you could be making your application better and shipping it faster.</p>
</div>
</blockquote>
</div>
<div class="paragraph">
<p>So how does that square with shared-nothing cluster nodes? The answer is simple: The nodes use DynamoDB to serialize all writes per database.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-_KGCQ-wrZik/Wmiro33YlBI/AAAAAAAAALQ/nLZWcVUlmRAJxaNbYmINXkLIq-vY-MC_wCLcBGAs/s1600/tx-ha-300-50.png" alt="Transaction HA diagram">
</div>
</div>
<div class="paragraph">
<p>At any point in time a database has a preferred node for transactions. In normal operation all transactions for a database will flow to/through that node. If for any reason (e.g. a temporary network partition) the preferred node can&#8217;t be reached, <em>any</em> node can and will handle transactions. Consistency is ensured by <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.ConditionalUpdate">conditional writes</a> to DynamoDB. If a node becomes unreachable, Datomic will choose a new preferred node.</p>
</div>
<div class="paragraph">
<p>Note in particular that:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>This is not a master/follower system like <a href="https://docs.datomic.com/operation/ha.html">Datomic On-Prem</a> and many other databases&#8201;&#8212;&#8201;nobody is tracking mastership and there are no failover intervals.</p>
</li>
<li>
<p>This should not be confused with parallel multi-writer systems such as Cassandra. Write availability is governed by the availability of DynamoDB conditional writes and <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html">strongly-consistent reads</a>.</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_is_aws_cool">Is AWS Cool?</h3>
<div class="paragraph">
<p>Very cool. Datomic Cloud showcases the benefit of designing for AWS vs. porting to AWS, and there is a lot going on behind zeroconf HA:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://aws.amazon.com/cloudformation/">CloudFormation</a> automates creation and updates the cluster</p>
</li>
<li>
<p><a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html">Application Load Balancers</a> distribute requests transparently to clients</p>
</li>
<li>
<p><a href="https://aws.amazon.com/autoscaling/">Auto Scaling Groups</a> and health checks maintain a healthy cluster</p>
</li>
<li>
<p>DynamoDB conditional writes ensure transaction semantics</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_so_what_else_have_you_got">So What Else Have You Got?</h3>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic is Free</a>. The pricing information here is outdated.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Not all systems need HA. You can prototype a Datomic Cloud system with the (non-HA) <a href="https://docs.datomic.com/cloud/operation/architecture.html#solo-topology">Solo Topology</a> for about $1/day. The topology differences are entirely abstracted away from clients and applications, so you can easily upgrade to the Production Topology later.</p>
</div>
</div>
<div class="sect2">
<h3 id="_for_more_information">For More Information:</h3>
<div class="paragraph">
<p>Check out the docs for</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.datomic.com/cloud/operation/ha.html">High Availability</a></p>
</li>
<li>
<p>the <a href="https://docs.datomic.com/cloud/operation/architecture.html">Production and Solo Topologies</a></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Or just <a href="https://docs.datomic.com/cloud/setting-up.html">jump right in</a>.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Cloud</title>
      <link>https://blog.datomic.com/2018/01/datomic-cloud.html</link>
      <pubDate>Wed, 17 Jan 2018 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2018/01/datomic-cloud.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p>Because <a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic Cloud is free</a>, it is no longer distributed via AWS Marketplace. Use CloudFormation instead; see <a href="https://docs.datomic.com/setup-cloud/cloud-setup.html">Datomic Cloud Setup</a>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic is Free</a>. The pricing and licensing information in this blog post is outdated.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><strong>Datomic On-Prem</strong> is now called <strong>Datomic Pro</strong>. This post uses the original name.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="sect2">
<h3 id="_datomic_on_aws_easy_integrated_and_powerful">Datomic on AWS: Easy, Integrated, and Powerful</h3>
<div class="paragraph">
<p>We are excited to announce the release of <a href="https://www.datomic.com/">Datomic Cloud</a>, making Datomic more accessible than ever before:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Easy</strong>: Datomic Cloud is an Amazon Marketplace AMI.</p>
<div class="ulist">
<ul>
<li>
<p><a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa?ref=vdr_rf">click through</a> a CloudFormation wizard and you can be <a href="https://www.datomic.com/videos.html#setting-up-video">up and running in minutes</a></p>
</li>
<li>
<p>start with the <a href="https://docs.datomic.com/operation/architecture.html#solo-topology">Solo Topology</a> (including AWS instance) for about $1/day, billed hourly</p>
</li>
<li>
<p><a href="${config.pricinglink}">itemized</a> on your regular AWS bill</p>
</li>
</ul>
</div>
</li>
<li>
<p><strong>Integrated</strong>: Datomic Cloud is closely integrated with AWS, <em>automatically</em> providing:</p>
<div class="ulist">
<ul>
<li>
<p>encryption at rest with key management by <a href="https://aws.amazon.com/kms/">KMS</a></p>
</li>
<li>
<p><a href="https://docs.datomic.com/operation/ha.html">clustered high availability</a> behind <a href="https://aws.amazon.com/elasticloadbalancing/">Application Load Balancers</a> (ALBs)</p>
</li>
<li>
<p><a href="https://docs.datomic.com/operation/growing-your-system.html"><em>elastic</em> read autoscaling</a> via <a href="https://aws.amazon.com/autoscaling/">autoscaling groups</a> without sharding</p>
</li>
<li>
<p><a href="https://docs.datomic.com/operation/architecture.html#storage-resources">redundant storage</a> across multiple highly-available, fault-tolerant storages: <a href="https://aws.amazon.com/dynamodb/">DynamoDB</a>, <a href="https://aws.amazon.com/s3/">S3</a>, and <a href="https://aws.amazon.com/efs/">EFS</a></p>
</li>
<li>
<p><a href="https://aws.amazon.com/cloudwatch/">CloudWatch metrics and dashboards</a> </p>
</li>
</ul>
</div>
</li>
<li>
<p><strong>Powerful</strong>: Datomic Cloud delivers the full Datomic information model</p>
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.datomic.com/transactions/acid.html">ACID transactions</a></p>
</li>
<li>
<p><a href="https://docs.datomic.com/query/query-data-reference.html">Datalog query</a> with joins, recursion, and rules</p>
</li>
<li>
<p><a href="https://docs.datomic.com/schema/schema-reference.html">a universal relation</a> supporting row, column, entity, and graph access</p>
</li>
<li>
<p><a href="https://docs.datomic.com/whatis/data-model.html#accumulate-only">indelible</a>, <a href="https://docs.datomic.com/whatis/data-model.html#time-model">chronological</a> storage so you can track data over time</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p>Datomic Cloud is a new product intended for greenfield development on AWS. If you are not yet targeting the cloud, check out what <a href="https://www.datomic.com/customers.html">customers are saying</a> about the established line of Datomic On-Prem products (Datomic Pro and Enterprise).</p>
</div>
<div class="paragraph">
<p>Datomic Cloud is accessible through the latest release of the <a href="https://docs.datomic.com/client/client-api.html">Datomic Client API</a>. To learn more, you can:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://www.datomic.com/videos.html#setting-up-video">see</a> how to set up in minutes</p>
</li>
<li>
<p><a href="https://docs.datomic.com/getting-started/getting-started.html">try it yourself</a></p>
</li>
<li>
<p><a href="https://docs.datomic.com/operation/architecture.html">learn more</a> about the architecture</p>
</li>
<li>
<p>review the <a href="http://docs.datomic.com/on-prem/cloud/moving-to-cloud.html">differences</a> between Cloud and On-Prem</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>We would love your feedback! Come and join us on the new <a href="https://forum.datomic.com/">developer forum</a>.</p>
</div>
<div class="paragraph">
<p><a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa?ref=vdr_rf"><span class="image"><img src="/images/blog/-RxcRgwasB3c/Wl0jyzGrOJI/AAAAAAAAAYI/i4KkQsM4BtUCkg3MwRME5ihyDNZ1DhvcwCLcBGAs/s1600/aws-marketplace-380x70.png" alt="Datomic Cloud on the AWS Marketplace"></span></a></p>
</div>
<div class="paragraph">
<p><a href="https://aws.amazon.com/marketplace/pp/prodview-otb76awcrb7aa?ref=vdr_rf">Datomic Cloud on the AWS Marketplace</a></p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Pull :as</title>
      <link>https://blog.datomic.com/2017/12/datomic-pull-as.html</link>
      <pubDate>Tue, 5 Dec 2017 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2017/12/datomic-pull-as.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Datomic&#8217;s <a href="https://docs.datomic.com/query/query-pull.html">Pull API</a> provides a declarative way to make hierarchical and nested selections of information about entities. The 0.9.5656 release enhances the Pull API with a new <code>:as</code> clause that provides control over the returned keys.</p>
</div>
<div class="paragraph">
<p>As an example, imagine that you want information about Led Zeppelin&#8217;s tracks from the <a href="https://github.com/Datomic/mbrainz-sample">mbrainz dataset</a>. The following pull pattern navigates to the artist&#8217;s tracks, using <code>limit</code> to return a single track:</p>
</div>

<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; pull expression
'[[:track/_artists :limit 1]]

=&gt; #:track{:_artists
 [#:db{:id 17592188757937}]}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The entity id <code>17592188757937</code> is not terribly interesting, so you can use a nested pull pattern to request the track name instead:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; pull pattern
'[{[:track/_artists :limit 1] [:track/name]}]

=&gt; #:track{:_artists [#:track{:name "Black Dog"}]}</code></pre>
</div>
</div>
<div class="paragraph">
<p>That is better, but what if you want different key names? This can happen for reasons including:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>you are targeting an environment that does not support symbolic names, so you need a string instead of a keyword key</p>
</li>
<li>
<p>you do not want to expose the <a href="https://docs.datomic.com/query/query-pull.html#reverse-lookup">direction of navigation</a> (e.g. the underscore in <code>:track/_artists</code>)</p>
</li>
<li>
<p>your consumers are expecting a different name</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The <code>:as</code> option lets you rename result keys to arbitrary values that you provide, and works at any level of nesting in a pull pattern. The pattern below uses <code>:as</code> twice to rename the two keys in the result:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; pull expression
'[{[:track/_artists :limit 1 :as "Tracks"]
 [[:track/name :as "Name"]]}]

=&gt; {"Tracks" [{"Name" "Black Dog"}]}</code></pre>
</div>
</div>
<div class="paragraph">
<p>To try it out you can <a href="https://my.datomic.com/">grab the latest release</a>, review the <a href="https://docs.datomic.com/query/query-pull.html#pull-grammar">Pull grammar</a>, and work through <a href="https://github.com/Datomic/day-of-datomic/blob/master/tutorial/pull.clj">these examples</a> at the REPL.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>New Datomic Training Videos and Getting Started Documentation</title>
      <link>https://blog.datomic.com/2017/03/new-datomic-training-videos-and-getting.html</link>
      <pubDate>Thu, 23 Mar 2017 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2017/03/new-datomic-training-videos-and-getting.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>We are excited to announce the release of a new set of <a href="https://www.datomic.com/training.html">Day of Datomic training videos</a>! Filmed at Clojure/Conj in Austin, TX in December of 2016, this series covers everything from the architecture and data model of Datomic to operation and scaling considerations.</p>
</div>

<div class="paragraph">
<p>The new training sessions provide a great foundation for developing a Datomic-based system. For those of you who have watched the original Day of Datomic videos, the series released today uses the new <a href="https://blog.datomic.com/2016/11/datomic-update-client-api-unlimited.html">Datomic Client library</a> for the examples and workshops, so if you haven&#8217;t yet explored Datomic Clients, now is the perfect opportunity to do so!</p>
</div>
<div class="paragraph">
<p>If you ever want to refer back to the original Peer-based training videos, don&#8217;t worry - they&#8217;re all still available as well.</p>
</div>
<div class="paragraph">
<p>In addition to an updated Day of Datomic, we&#8217;ve released a fully re-organized and re-written <a href="https://docs.datomic.com/datomic-overview.html">Getting Started</a> section in the <a href="https://docs.datomic.com/">Datomic Documentation</a>. We have gathered and incorporated feedback from new and existing users and hope that the new Getting Started is a much more comprehensive and accessible introduction to Datomic.</p>
</div>
<div class="paragraph">
<p>We look forward to your thoughts and feedback. If you have any comments on the <a href="https://www.datomic.com/training.html">new training videos</a>, the <a href="https://docs.datomic.com/datomic-overview.html">new getting started section,</a> or any additional thoughts, please let us know!</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>The Ten Rules of Schema Growth</title>
      <link>https://blog.datomic.com/2017/01/the-ten-rules-of-schema-growth.html</link>
      <pubDate>Wed, 25 Jan 2017 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2017/01/the-ten-rules-of-schema-growth.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Data outlives code, and a valuable database supports many applications over time. These ten rules will help grow your database schema without breaking your applications.</p>
</div>
<div class="sect2">
<h3 id="_1_prod_is_not_like_dev">1. Prod is not like dev.</h3>
<div class="paragraph">
<p>Production is not development. In production, one or more codebases depend on your data, and these ten rules below should be followed exactingly.</p>
</div>

<div class="paragraph">
<p>A dev environment can be much more relaxed. Alone on your development machine experimenting with a new feature, you have no users to break. You can soften the rules, so long as you harden them when transitioning to production.</p>
</div>
</div>
<div class="sect2">
<h3 id="_2_grow_your_schema_and_never_break_it">2. Grow your schema, and never break it.</h3>
<div class="paragraph">
<p>The lack of common vocabulary makes it all too easy to automate the wrong practices. I will use the terms <em>growth</em> and <em>breakage</em> as defined in Rich Hickey&#8217;s <a href="https://www.youtube.com/watch?v=oyLBGkS5ICk">Spec-ulation</a> talk. In schema terms:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><em>growth</em> is providing more schema</p>
</li>
<li>
<p><em>breakage</em> is removing schema, or changing the meaning of existing schema.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In contrast to these terms, many people use "<a href="https://edgeguides.rubyonrails.org/active_record_migrations.html">migrations</a>", "<a href="https://databaserefactoring.com/">refactoring</a>", or "<a href="https://martinfowler.com/articles/evodb.html">evolution</a>". These usages tend to focus on repeatability, convenience, and the needs of new programs, ignoring the distinction between growth and breakage. The problem here is obvious: Breakage is bad, so we don&#8217;t want it to be more convenient!</p>
</div>
<div class="paragraph">
<p>Using precise language underscores the costs of breakage. Most migrations are easily categorized as growth or breakage by considering the rules below. <em>Growth migrations</em> are suitable for production, and <em>breakage migrations</em> are, at best, a dev-only convenience. Keep them widely separate.</p>
</div>
</div>
<div class="sect2">
<h3 id="_3_the_database_is_the_source_of_truth">3. The database is the source of truth.</h3>
<div class="paragraph">
<p>Schema growth needs to be reproducible from one environment to another. Reproducibility supports the development and testing of new schema before putting it into production and also the reuse of schema in different databases. Schema growth also needs to be evident in the database itself, so that you can determine what the database has, what it needs, and when growth occurred.</p>
</div>
<div class="paragraph">
<p>For both of these reasons, the database is the proper source of truth for schema growth. When the database is the source of truth, reproducability and auditability happen <em>for free</em> via the ordinary query and transaction capabilities of the database. (If your database is not up to the tasks of queries and transactions you have bigger problems beyond the scope of this article).</p>
</div>
<div class="paragraph">
<p>Storing schema in a database is strictly more powerful than storing schema as text files in source control. The database is the actual home for schema, plus it provides validation, structure, query, transactions, and history. A source control system provides only history and is separate from the data itself.</p>
</div>
<div class="paragraph">
<p>Note that this does <em>not</em> mean "never put schema information in source control". Source control may be convenient for other reasons, e.g. it may be more readily accessible. You may redundantly store schema in source control, but remember that the database is definitive.</p>
</div>
</div>
<div class="sect2">
<h3 id="_4_growing_is_adding">4. Growing is adding.</h3>
<div class="paragraph">
<p>As you acquire more information about your domain, grow your schema to match. You can grow a schema by adding new things, and <em>only</em> by adding new things, for example:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>adding new attributes to an existing 'type'</p>
</li>
<li>
<p>adding new types</p>
</li>
<li>
<p>adding relationships between types</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_5_never_remove_a_name">5. Never remove a name.</h3>
<div class="paragraph">
<p>Removing a named schema component at any level is a breaking change for programs that depend on that name. Never remove a name.</p>
</div>
</div>
<div class="sect2">
<h3 id="_6_never_reuse_a_name">6. Never reuse a name.</h3>
<div class="paragraph">
<p>The meaning of a name is established when the name is first introduced. Reusing that name to mean something substantially different breaks programs that depend on that meaning. This can be even worse than removing the name, as the breakage may not be as immediately obvious.</p>
</div>
</div>
<div class="sect2">
<h3 id="_7_use_aliases">7. Use aliases.</h3>
<div class="paragraph">
<p>If you are familiar with database refactoring patterns, the advice in Rules Five and Six may seem stark. After all, one purpose of refactoring is to adopt better names as we discover them. How can we do that if names can never be removed or changed in meaning?</p>
</div>
<div class="paragraph">
<p>The simple solution is to use <a href="https://docs.datomic.com/schema/schema-change.html#changing-db-ident">more than one alias</a> to refer to the same schema entity. Consider the following example:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In iteration 1, users of your system are identified by their email with an attribute named <code><strong>:user/id</strong></code>.</p>
</li>
<li>
<p>In iteration 2, you discover that users sometimes have non-email identifiers for users and that you want to store a user&#8217;s email even when not using the email as an identifier. In short, you wish that <code><strong>:user/id</strong></code> was named <code><strong>:user/primary-email</strong></code>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>No problem! Just create <code><strong>:user/primary-email</strong></code> as an alias for <code><strong>:user/id</strong></code>. Older programs can continue to use <code><strong>:user/id</strong></code>, and newer programs can use the now-preferred <code><strong>:user/primary-email</strong></code>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_8_namespace_all_names">8. Namespace all names.</h3>
<div class="paragraph">
<p>Namespaces greatly reduce the cost of getting a name wrong, as the same local name can safely have different meanings in different namespaces. Continuing the previous example, imagine that the local name <code><strong>id</strong></code> is used to refer to a UUID in several namespaces, e.g. <code><strong>:inventory/id</strong></code>, <code><strong>:order/id</strong></code>, and so on. The fact that <code><strong>:user/id</strong></code> is <em>not</em> a UUID is inconsistent, and newer programs should not have to put up with this.</p>
</div>
<div class="paragraph">
<p>Namespaces let you improve the situation without breaking existing programs. You can introduce <code><strong>:user-v2/id</strong></code>, and new programs can ignore names in the <code><strong>user</strong></code> namespace. If you don&#8217;t like <code><strong>v2</strong></code>, you can also pick a more semantic name for the new namespace.</p>
</div>
</div>
<div class="sect2">
<h3 id="_9_annotate_your_schema">9. Annotate your schema.</h3>
<div class="paragraph">
<p>Databases are good at storing data about your schema. Adding annotations to your schema can help both human readers and make sense of how the schema grew over time. For example:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>you could annotate names that are not recommended for new programs with a <code><strong>:schema/deprecated</strong></code> flag, or you could get fancier still with <code><strong>:schema/deprecated-at</strong></code> or <code><strong>:schema/deprecated-because</strong></code>. Note that such deprecated names are still <em>never</em> removed (Rule Five).</p>
</li>
<li>
<p>you could provide <code><strong>:schema/see-also</strong></code> or <code><strong>:schema/see-instead</strong></code> pointers to more current conventions.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In fact, all the database refactoring patterns that are typically implemented as breaking changes could be implemented non-destructively, with the refactoring details recorded as an annotation. For example, the breaking <a href="https://databaserefactoring.com/SplitColumns.html">"split column" refactoring</a> might instead be implemented as schema growth:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>add N new columns</p>
</li>
<li>
<p>(optional) add a <code><strong>:schema/split-into</strong></code> attribute on the original column whose value is the new columns, and possibly even the recipe for the split</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_10_plan_for_accretion">10. Plan for accretion.</h3>
<div class="paragraph">
<p>If a system is going to grow at all, then programs must not bake in limiting presumptions. For example: If a schema states that <code><strong>:user/id</strong></code> is a string, then programs can rely on <code><strong>:user/id</strong></code> being a string and not occasionally an integer or a boolean. But a program cannot assume that a user entity will be limited to a the set of attributes previously seen, or that it understands the semantics of attributes that it has not seen before.</p>
</div>
</div>
<div class="sect2">
<h3 id="_are_these_rules_specific_to_a_particular_database">Are these rules specific to a particular database?</h3>
<div class="paragraph">
<p>No. These rules apply to almost any SQL or NoSQL database. The rules even apply to the so-called "schemaless" databases. A better word for schemaless is "schema-implicit", i.e. the schema is implicit in your data and the database has no reified awareness of it. With an implicit schema, all the rules still apply, except that the database is impotent to help you (no Rule 3).</p>
</div>
</div>
<div class="sect2">
<h3 id="_in_context">In Context</h3>
<div class="paragraph">
<p>Many of the resources on migrations, refactoring, and database evolution emphasize repeatability and the needs of new programs, without making the top-level distinctions of growth vs. breakage and prod vs. dev. As a result, these resources encourage breaking the rules in this article.</p>
</div>
<div class="paragraph">
<p>Happily, these resources can easily be recast in growth-only terms. You <em>can</em> grow your schema without breaking your app. You <em>can</em> continuously deploy without continuously propagating breakage. Here&#8217;s what it looks like <a href="https://docs.datomic.com/reference/best.html#production-schema">in Datomic</a>.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Customer Feedback Portal</title>
      <link>https://blog.datomic.com/2016/12/customer-feedback-portal.html</link>
      <pubDate>Wed, 14 Dec 2016 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2016/12/customer-feedback-portal.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Receptive has been closed, and feature requests moved to the <a href="https://ask.datomic.com">Datomic Knowledgebase</a>.</p>
</div>

<div class="paragraph">
<p>The rest of this post is left for posterity.</p>
</div>
<hr>
<div class="paragraph">
<p>As part of our commitment to improving Datomic, a few weeks ago we enabled a new feature request and user feedback system, Receptive.io, where you can help us prioritize our efforts and help shape the future of Datomic.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-53l7suMbyss/WDw4_QYOk5I/AAAAAAAAANQ/MmACZ8DAbKsE8tE4BzI4I6Y81tt18aJtwCPcB/s200/DatomicLogo_Square.png" alt="Datomic Logo">
</div>
</div>
<div class="paragraph">
<p>To submit your feature request follow the "Suggest Features" link in the top navigation of the <a href="http://my.datomic.com/">my.datomic.com</a> dashboard. We have already connected your account to Receptive.io so everything is set up and ready for you to go.</p>
</div>
<div class="paragraph">
<p>You can read more about using Receptive <a href="https://help.receptive.io/hc/en-us/articles/210845605-How-to-suggest-features-with-Receptive">here</a>.</p>
</div>
<div class="paragraph">
<p>-The Datomic Team</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Update: Client API, Unlimited Peers, Enterprise Edition, and More</title>
      <link>https://blog.datomic.com/2016/11/datomic-update-client-api-unlimited.html</link>
      <pubDate>Mon, 28 Nov 2016 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2016/11/datomic-update-client-api-unlimited.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic is Free</a>. The pricing and licensing information in this blog post is outdated.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>We are pleased to announce that the latest (0.9.5530) release of Datomic includes a set of new features and licensing changes to address needs identified by our customers:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In addition to the peer model, Datomic now includes a <a href="https://docs.datomic.com/reference/clients-and-peers.html">Client API</a> suitable for smaller, short lived processes, e.g. microservices.</p>
</li>
<li>
<p>The various tiers of the Datomic Pro license model have been simplified to a <a href="https://www.datomic.com/get-datomic.html">single license</a> with no restriction on peer count.</p>
</li>
<li>
<p>We have introduced an <a href="https://www.datomic.com/get-datomic.html">Enterprise license tier</a> for users who need customized pricing, support, or licensing terms.</p>
</li>
<li>
<p><a href="https://docs.datomic.com/transactions/transaction-processing.html#temporary-ids">Tempids</a> and explicit <a href="https://docs.datomic.com/schema/schema-reference.html#partitions">partitions</a> are now optional, simplifying code for the many programs that do not care about them.</p>
</li>
<li>
<p>Schema install and update are now implicit, and do not require <a href="https://docs.datomic.com/schema/schema-reference.html#explicit-schema">explicit</a> <code>:db.install/attribute</code> or <code>:db.update/attribute</code> datoms.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The features described above are additive and opt-in, so take advantage of them as and when you please.</p>
</div>
<div class="paragraph">
<p>Each of these changes is described in more detail below.</p>
</div>
<div class="sect2">
<h3 id="_building_on_a_solid_foundation">Building On a Solid Foundation</h3>
<div class="paragraph">
<p>Before talking about what is new, it is important to talk about what is unchanged. We built Datomic believing that the <a href="https://www.datomic.com/rationale.html">Rationale</a> is a sound foundation for an information system, and experience has proven this out. We have not retracted a word of the rationale since day one, and are not doing so today. Datomic&#8217;s core ideas are unchanged:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>getting time, process, and perception right</p>
</li>
<li>
<p>sound data model</p>
</li>
<li>
<p>ACID transactions</p>
</li>
<li>
<p>Datalog query</p>
</li>
<li>
<p>minimal schema</p>
</li>
<li>
<p>separate reads and writes</p>
</li>
<li>
<p>programming with data</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Datomic has delivered these ideas with a discipline that minimizes breaking API change. As a result, Datomic users have been able to focus on their business problems without having to worry about changing semantics in their database.</p>
</div>
</div>
<div class="sect2">
<h3 id="_client_api">Client API</h3>
<div class="paragraph">
<p>Datomic&#8217;s peer library puts database query in your own application process. This provides several benefits, but at the price of a heavier dependency (both in code and in memory requirements) than a traditional client.</p>
</div>
<div class="paragraph">
<p>A smaller footprint is useful in environments that have operational limitations, or where processes are small or short-lived. The new Datomic client API addresses this need. Lightweight clients connect to <a href="https://docs.datomic.com/operation/peer-server.html">Peer Servers</a>, which are peers that run in a separate address space.</p>
</div>
<div class="paragraph">
<p>Existing peers are unchanged, and you can mix and match peer and client applications as you see fit within the same Datomic install. Clients and peers are described in detail in the new <a href="https://docs.datomic.com/reference/clients-and-peers.html">clients and peers</a> section of the docs.</p>
</div>
<div class="paragraph">
<p>With today&#8217;s release, we are making available the alpha version of the open source Client library for Clojure. The Java library will be released shortly. We also have plans to both create more language libraries for Client and enable our customers to create their own. We are interested in your feedback on the Client API itself and the priority of our language reach efforts. As of today, we have enabled a customer feedback portal, accessible via the "Suggest Features" link in the top navigation of the <a href="http://my.datomic.com/">my.datomic.com</a> dashboard, where you can help us prioritize our efforts in this (and many other) areas.</p>
</div>
</div>
<div class="sect2">
<h3 id="_unlimited_peers">Unlimited Peers</h3>
<div class="paragraph">
<p>Flexibility in Peer use has been the most often-requested update to Datomic. You are solving complex problems using cutting edge technologies and architectures. Your tools should allow you to design the system that best fits your needs. Datomic&#8217;s new licensing model gives all users - Starter, Pro and Enterprise - the ability to design for and deploy as many Peer processes (and Clients!) as their systems require. Today&#8217;s release represents a massive upgrade to the potential of each (new and existing) Datomic installation.</p>
</div>
</div>
<div class="sect2">
<h3 id="_pro_starter_license">Pro Starter License</h3>
<div class="paragraph">
<p>The Pro Starter license provides a no-cost way to try Datomic. You get a perpetual license plus a year of software upgrades for free. Starting with this release, Pro Starter includes all the features of a Pro license, including</p>
</div>
<div class="ulist">
<ul>
<li>
<p>unlimited peers</p>
</li>
<li>
<p>clients</p>
</li>
<li>
<p>High Availability (HA)</p>
</li>
<li>
<p>integrated memcached</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_enterprise_tier">Enterprise Tier</h3>
<div class="paragraph">
<p>Datomic has a number of enterprise customers already. They distinguish themselves by wanting</p>
</div>
<div class="ulist">
<ul>
<li>
<p>custom license terms</p>
</li>
<li>
<p>custom pricing for larger installations</p>
</li>
<li>
<p>custom support terms</p>
</li>
<li>
<p>custom development</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>If you match one or more of these criteria, <a href="https://www.datomic.com/contact.html">contact us</a> to discuss an Enterprise license.</p>
</div>
</div>
<div class="sect2">
<h3 id="_tempid_and_partition_defaults">Tempid and Partition Defaults</h3>
<div class="paragraph">
<p>Datomic&#8217;s tempids provide a way to <a href="https://docs.datomic.com/schema/schema-reference.html#partitions">partition</a> new entities, encoding a locality hint directly in transactions. This feature is powerful, but rarely used, and the API and data structure for tempids are an inconvenience for the majority of users, who do not need or want partition control.</p>
</div>
<div class="paragraph">
<p>Starting with the current release of Datomic:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.datomic.com/transactions/transaction-processing.html#temporary-ids">tempids</a> are optional</p>
</li>
<li>
<p>when you need a tempid to coordinate the relationship between two entities, you can use an ordinary string instead of a tempid structure, and that string can be meaningful to readers of your code</p>
</li>
<li>
<p>the existing tempid data structure and API continue to be supported unchanged. Use them if you want them.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Clients will support string tempids only.</p>
</div>
</div>
<div class="sect2">
<h3 id="_schema_install_and_update">Schema Install and Update</h3>
<div class="paragraph">
<p>Transactions that change attribute schema must include either <code>:db.install/attribute</code> (to create an attribute) or <code>:db.alter/attribute</code> (to change an existing attribute). The new release of Datomic <a href="https://docs.datomic.com/schema/schema-reference.html#explicit-schema">infers the need</a> for these datoms and adds them to your transaction automatically, reducing the verbosity of schema data.</p>
</div>
</div>
<div class="sect2">
<h3 id="_conclusion">Conclusion</h3>
<div class="paragraph">
<p>We are very excited about the additions and changes to Datomic. To celebrate, we will be offering a 20% discount on new Datomic purchases through the end of February 2017. We hope you take advantage of the new features and this discount opportunity and please feel free to reach out to us at anytime.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Log API for Memory Databases</title>
      <link>https://blog.datomic.com/2016/08/log-api-for-memory-databases.html</link>
      <pubDate>Wed, 10 Aug 2016 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2016/08/log-api-for-memory-databases.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>The most recent <a href="https://groups.google.com/d/topic/datomic/QLdZ_WePR5A/discussion">Datomic Release</a> provides access to the Datomic <a href="https://docs.datomic.com/reference/log.html">Log API</a> for memory databases. I would like to take this opportunity to describe some of the features and uses of the Datomic Log API.</p>
</div>
<div class="paragraph">
<p>The transactional log is a fundamental component of <a href="https://docs.datomic.com/transactions/acid.html">ACID</a> database systems, a durable record of the transactions performed by the database. In addition to its critical function in ensuring ACID semantics, the Datomic log, as a sequential (in database time, <code>t</code>) record of all transactions, also functions as a time-ordered index to the data stored in a Datomic database.</p>
</div>

<div class="paragraph">
<p>Datomic provides access to the transaction log directly via the <a href="https://docs.datomic.com/clojure/#datomic.api/tx-range"><em>tx-range</em> function</a> and from within query using the <a href="https://docs.datomic.com/reference/log.html#log-in-query"><em>tx-ids</em> and <em>tx-data</em> functions</a>.</p>
</div>
<div class="paragraph">
<p>An <a href="https://github.com/Datomic/day-of-datomic/blob/master/tutorial/log.clj">example</a> using the log in query is now available in the <a href="https://github.com/Datomic/day-of-datomic">Day of Datomic</a> repo. Our example database records the streets on which our three protagonists, John, Mary, and Joe, live.</p>
</div>
<div class="paragraph">
<p>Let&#8217;s find out when Joe moved to Broadway:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/q '[:find ?tx
 :in $ ?name ?street
 :where
 [?e :person/name ?name]
 [?e :person/street ?street ?tx true]]
 (d/history (d/db conn)) "Joe" "Broadway")</code></pre>
</div>
</div>
<div class="paragraph">
<p>This query returns <code>13194139534317</code>, the transaction ID of the transaction that asserted Joe&#8217;s street is Broadway. As in all Datomic databases, every transaction also records a timestamp, the <em>:db/txInstant</em>. Let&#8217;s see what wall-clock time is associated with this transaction entity:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/pull (d/db conn) '[:db/txInstant] 13194139534317)</code></pre>
</div>
</div>
<div class="paragraph">
<p>So Joe moved to Broadway in 1983.</p>
</div>
<div class="paragraph">
<p>Issuing queries against the transaction log is a powerful approach for auditing the operational history of a database. Because <a href="https://blog.datomic.com/2015/12/reified-transactions.html">every transaction is an entity</a> in Datomic, we can easily retrieve the entire set of datoms for a given transaction entity. Let&#8217;s find out what else happened in the 'Joe moves to Broadway' transaction. This query returns all the datoms associated with the given transaction:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/q '[:find ?e ?a ?v ?tx ?op
 :in ?log ?tx
 :where [(tx-data ?log ?tx)[[?e ?a ?v _ ?op]]]]
 (d/log conn) 13194139534317)

;; result:
#{[17592186045420 64 "2nd" 13194139534317 true]
 [17592186045419 64 "Broadway" 13194139534317 true]
 [13194139534317 50 #inst"1983-01-01T00:00:00.000-00:00" 13194139534317 true]
 [17592186045420 64 "Elm" 13194139534317 false]
 [17592186045419 64 "1st" 13194139534317 false]}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Note that we see the same wall clock time we found previously as well as 4 other datoms. One is the assertion of Joe moving to Broadway, one is the retraction of his previous street (1st), and the remaining two datoms are about someone else entirely. Let&#8217;s find out who:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/pull (d/db conn) '[*] 17592186045420)

;; result:
{:db/id 17592186045420, :person/name "Mary", :person/street "2nd"}</code></pre>
</div>
</div>
<div class="paragraph">
<p>By using the log, we&#8217;ve determined that Mary&#8217;s move to 2nd Street was recorded at the same time (during the same transaction) as Joe&#8217;s move to Broadway.</p>
</div>
<div class="paragraph">
<p>The ability to query the Datomic transaction log directly is a powerful tool for managing, administering, and using a Datomic database. The addition of the Log API to memory databases enables low-overhead testing and evaluation of Datomic&#8217;s Log API feature. We hope you find the Log API on memory databases a helpful addition for lightweight development and unit testing.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>You Might Not Need an ORM</title>
      <link>https://blog.datomic.com/2016/04/you-might-not-need-orm.html</link>
      <pubDate>Sat, 23 Apr 2016 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2016/04/you-might-not-need-orm.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Over the last few months, my colleague Michael Nygard has been writing <a href="https://cognitect.com/blog/">The New Normal</a> series over on the <a href="https://cognitect.com/blog/">Cognitect blog</a>, arguing that our industry needs to embrace continuous partial failure and aim to build <a href="https://cognitect.com/blog/2016/2/18/the-new-normal-from-resilient-to-antifragile">antifragile</a> systems.</p>
</div>

<div class="paragraph">
<p>In his <a href="https://cognitect.com/blog/2016/4/22/the-new-normal-everything-relies-on-sharp-tools">most recent installment</a>, Mike shares some ideas on sharp tools and their value in eliminating code. Mike worked with several teams that considered object-relational mapping (ORM) for <a href="https://www.datomic.com/">Datomic</a>, concluding that with Datomic, you don&#8217;t need ORM at all. Datomic lets you eliminate an entire architectural layer from your applications.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Reified Transactions</title>
      <link>https://blog.datomic.com/2015/12/reified-transactions.html</link>
      <pubDate>Thu, 3 Dec 2015 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2015/12/reified-transactions.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Domain data often answers the question "what", e.g.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>What products are in inventory?</p>
</li>
<li>
<p>What users have accounts on the system?</p>
</li>
<li>
<p>What tests have been run?</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>But many domains also include information about the provenance of data, e.g.</p>
</div>

<div class="ulist">
<ul>
<li>
<p>Who said this data was correct?</p>
</li>
<li>
<p>When should this data be published?</p>
</li>
<li>
<p>Where did this data come from?</p>
</li>
<li>
<p>Why was this correction necessary?</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>How should you model this "data about data"? Datomic stores (and lets you store) facts about transactions themselves. In other words, transactions are themselves <em>reified</em> as data in the system.</p>
</div>
<div class="paragraph">
<p>Tim Ewald gave a great talk about this at Datomic Conf. His talk and all the other Datomic Conf talks are now freely available <a href="https://www.datomic.com/videos.html">online</a>.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>CQRS with Clojure, Kafka, and Datomic</title>
      <link>https://blog.datomic.com/2015/11/cqrs-with-clojure-kafka-and-datomic.html</link>
      <pubDate>Tue, 24 Nov 2015 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2015/11/cqrs-with-clojure-kafka-and-datomic.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Datomic&#8217;s <a href="https://docs.datomic.com/datomic-overview.html#topology">clean separation of reads and writes</a> has inspired many comparisons with the <a href="https://martinfowler.com/bliki/CQRS.html">CQRS</a> (Command and Query Responsibility Segregation) architectural pattern.</p>
</div>

<div class="paragraph">
<p>One person who has traveled far down this road is Bobby Calderwood, a member of the Technology Fellows team at Capital One. Check out his recent <a href="https://www.youtube.com/watch?v=qDNPQo9UmJA">Clojure/conj talk</a>, where he demonstrates a complete CQRS implementation using <a href="https://clojure.org/">Clojure</a> microservices, Kafka, and Datomic.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Yeller chooses Datomic</title>
      <link>https://blog.datomic.com/2015/11/yeller-chooses-datomic.html</link>
      <pubDate>Thu, 5 Nov 2015 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2015/11/yeller-chooses-datomic.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p><a href="http://yellerapp.com/">Yeller</a> is an exception tracking service whose goal is to provide clear, actionable information to developers to take the pain out of examining application errors. They chose <a href="https://clojure.org/">Clojure</a> and <a href="https://www.datomic.com/">Datomic</a> as the platform for Yeller in order to make the development process more effective and more efficient.</p>
</div>

<div class="paragraph">
<p>You can read all about their reasons for <a href="http://yellerapp.com/posts/2015-09-21-datomic-clojure-benefits.html">choosing Clojure and Datomic on their blog</a>. You can also watch <a href="https://www.youtube.com/watch?v=0tUrbf6Uzu8&amp;list=PLZdCLR02grLoBx0Y5ZrpdmLxc160PIwzQ&amp;index=17">Tom explain it all at EuroClojure 2015</a>.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Nubank chooses Datomic</title>
      <link>https://blog.datomic.com/2015/09/nubank-chooses-datomic.html</link>
      <pubDate>Mon, 14 Sep 2015 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2015/09/nubank-chooses-datomic.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Brazil is the world&#8217;s 5th largest country in both area and population, has the 2nd most airports (behind the United States), and one of the highest credit card interest rates in the world. The Brazilian banking industry is both heavily regulated and extremely concentrated. Enter Nubank, whose founders have created a banking alternative in one of the world&#8217;s fastest growing mobile markets.</p>
</div>

<div class="paragraph">
<p>Traditional software wasn&#8217;t going to get the job done for Nubank. From the very beginning, the goal was "differentiation through technology." They needed to plan for growth, both in size and complexity, to meet constantly changing regulatory and business rules.</p>
</div>
<div class="paragraph">
<p>Nubank turned to <a href="https://www.datomic.com/">Datomic</a> to access multiple data stores simultaneously, process transactions, and easily query historical data. Engineers can perform complex analyses on real-time data while the performance of the production environment is preserved. Along the way, the <a href="https://cognitect.com/">Cognitect</a> team helped steer Nubank&#8217;s engineers on the right path as they built Datomic into their business.</p>
</div>
<div class="paragraph">
<p>Read the <a href="https://www.datomic.com/nubanks-story.html">full case study</a> to see how Datomic and <a href="https://clojure.org/">Clojure</a> are helping Nubank change the banking industry.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>A Conversational Introduction to Datomic</title>
      <link>https://blog.datomic.com/2015/08/a-conversational-introduction-to-datomic.html</link>
      <pubDate>Thu, 20 Aug 2015 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2015/08/a-conversational-introduction-to-datomic.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>My colleague Carin Meier has been writing up <a href="http://gigasquidsoftware.com/blog/2015/08/15/conversations-with-datomic/">her</a> <a href="http://gigasquidsoftware.com/blog/2015/08/19/conversations-with-datomic-part-2/">conversations</a> with <a href="https://www.datomic.com/">Datomic</a>, introducing the database via an imagined dialog between a new user and the database. In a very short space she introduces</p>
</div>

<div class="ulist">
<ul>
<li>
<p>rapid development against a memory database</p>
</li>
<li>
<p><a href="https://docs.datomic.com/schema/schema-reference.html#defining-schema">schema</a> definition</p>
</li>
<li>
<p>hierarchical selection with <a href="https://docs.datomic.com/query/query-pull.html">pull</a></p>
</li>
<li>
<p>Datalog <a href="https://docs.datomic.com/query/query-data-reference.html">query</a></p>
</li>
<li>
<p>strong <a href="https://docs.datomic.com/transactions/acid.html#consistency">consistency</a></p>
</li>
<li>
<p>retractions and <a href="https://docs.datomic.com/reference/filters.html#history">history</a></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Carin puts all these ideas into context with examples that you can explore in minutes. If you are new to Datomic, check it out.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Best Practices</title>
      <link>https://blog.datomic.com/2015/07/datomic-best-practices.html</link>
      <pubDate>Tue, 7 Jul 2015 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2015/07/datomic-best-practices.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>We are happy to announce the addition of a <a href="https://docs.datomic.com/reference/best.html">Best Practices</a> section to the Datomic Development Resources documentation. The Best Practices topic is a tool to help users quickly find preferred usage patterns when approaching common scenarios in Datomic.</p>
</div>

<div class="paragraph">
<p>The Datomic Best Practices documentation includes sections on:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.datomic.com/reference/best.html#datomic-schema">Designing Schema</a></p>
</li>
<li>
<p><a href="https://docs.datomic.com/reference/best.html#datomic-transaction">Transaction Strategies</a></p>
</li>
<li>
<p><a href="https://docs.datomic.com/reference/best.html#datomic-query">Building and Optimizing Queries</a></p>
</li>
<li>
<p><a href="https://docs.datomic.com/reference/best.html#datomic-time">Time in Datomic</a></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Where appropriate, examples are included as are links to the full documentation for further reading.</p>
</div>
<div class="paragraph">
<p>See the <a href="https://docs.datomic.com/reference/best.html">Best Practices documentation</a> for the full list. We expect to add more subtopics to the Best Practices documentation over time, so check back periodically.</p>
</div>
<div class="paragraph">
<p>We look forward to your feedback. If you have any comments on the new best practices topics, or any questions you think would be addressed by an additional topic, let us know!</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>More Power for Datomic Datalog: Negation, Disjunction, and Range Optimizations</title>
      <link>https://blog.datomic.com/2015/01/datalog-enhancements.html</link>
      <pubDate>Tue, 13 Jan 2015 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2015/01/datalog-enhancements.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Today&#8217;s <a href="https://www.datomic.com/">Datomic</a> release includes a number of enhancements to Datomic&#8217;s Datalog query language:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Negation, via the new <em>not</em> and <em>not-join</em> clauses</p>
</li>
<li>
<p>Disjunction (<em>or</em>) without using rules, via the new <em>or</em> and <em>or-join</em> clauses</p>
</li>
<li>
<p>Required rule bindings</p>
</li>
<li>
<p>Improved optimization of range predicates</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Each is described below, and you can follow the examples from the <a href="https://github.com/Datomic/mbrainz-sample">mbrainz data set</a> in <a href="https://github.com/Datomic/datomic-java-examples/blob/master/src/java/datomic/samples/Query.java">Java</a> or in <a href="https://github.com/Datomic/day-of-datomic/blob/master/tutorial/query.clj">Clojure</a>.</p>
</div>

<div class="sect2">
<h3 id="_negation">Negation</h3>
<div class="paragraph">
<p>The <code>not</code> clause shrinks a result set, removing already-bound tuples whose variables match a set of clauses.</p>
</div>
<div class="paragraph">
<p>For example, the following query finds the names of all artists who are not Canadian:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">[:find ?name
 :where [?eid :artist/name ?name]
 (not [?eid :artist/country :country/CA])]</code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>not-join</code> clause generalizes <code>not</code>, and allows you to also specify which variables inside the <code>not-join</code> will unify with the enclosing query.</p>
</div>
<div class="paragraph">
<p>The following query counts artists who did <em>not</em> release an album in 1970. The <code>not-join</code> specifies that <code>?artist</code> unifies with the containing query, and (implicitly) that <code>?release</code> is local.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">[:find (count ?artist) .
 :where [?artist :artist/name]
 (not-join [?artist]
 [?release :release/artists ?artist]
 [?release :release/year 1970])]</code></pre>
</div>
</div>
<div class="paragraph">
<p>As elsewhere in Datomic Datalog, lists of clauses inside <code>not</code> or <code>not-join</code> are connected by an implicit <em>and</em>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_disjunction">Disjunction</h3>
<div class="paragraph">
<p>Datomic Datalog has long supported disjunction (<em>or</em>) via <a href="https://docs.datomic.com/query/query-data-reference.html#rules">rules</a>. Rules are a powerful abstraction mechanism, allowing you to create named pieces of logic to be reused across multiple queries. Rules are also the path to recursion in query. But sometimes you don&#8217;t need all that, and you just want simple disjunction in situ.</p>
</div>
<div class="paragraph">
<p>The <em>or</em> clause binds variables that match at least one of a set of predicates.</p>
</div>
<div class="paragraph">
<p>As an example, consider the way mbrainz models release media. There are four separate enums that all represent vinyl: <em>vinyl</em>, <em>vinyl-7</em>, <em>vinyl-10</em>, and <em>vinyl-12</em>. An <code>or</code> clause can group these all together, finding all the vinyl releases:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">[:find (count ?medium) .
 :where (or [?medium :medium/format :medium.format/vinyl7]
 [?medium :medium/format :medium.format/vinyl10]
 [?medium :medium/format :medium.format/vinyl12]
 [?medium :medium/format :medium.format/vinyl])]</code></pre>
</div>
</div>
<div class="paragraph">
<p>The <em>and</em> clause is available as an explicit form inside <code>or</code> clauses. For example, the following query finds artists that are either groups or female individuals:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">[:find (count ?artist) .
 :where (or [?artist :artist/type :artist.type/group]
 (and [?artist :artist/type :artist.type/person]
 [?artist :artist/gender :artist.gender/female]))]</code></pre>
</div>
</div>
<div class="paragraph">
<p>Note that <code>and</code> clauses are used only inside <code>or</code>&#8201;&#8212;&#8201;elsewhere in query, <em>and</em> is implicit wherever clauses appear sequentially.</p>
</div>
<div class="paragraph">
<p>The <code>or-join</code> clause is a generalization of <code>or</code>, just as <code>not-join</code> generalizes <code>not</code>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_all_together">All Together</h3>
<div class="paragraph">
<p>Negation and disjunction can be nested, allowing direct expression of e.g. 'not this or that', e.g.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">[:find ?name
 :where [?eid :artist/name ?name]
 (not (or [?eid :artist/country :country/US])
 [?eid :artist/country :country/CA])]</code></pre>
</div>
</div>
<div class="paragraph">
<p>which means "find all the artists, except those that are from the US or Canada."</p>
</div>
</div>
<div class="sect2">
<h3 id="_required_rule_bindings">Required Rule Bindings</h3>
<div class="paragraph">
<p>Rules are relational, and do not dictate the order in which variables are bound. Imagine a rule that finds tracks shorter than a certain maximum length for an artist. You might write that rule as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">[(short-track ?a ?t ?len ?max)
 [?t :track/artists ?a]
 [?t :track/duration ?len]
 [(&lt; ?len ?max)]]</code></pre>
</div>
</div>
<div class="paragraph">
<p>This rule does not tell the caller anything about when the four variables might be bound, revealing little about its use. You might try to</p>
</div>
<div class="ulist">
<ul>
<li>
<p>invoke the rule in a context where no variables are bound yet, finding all possible relationships</p>
</li>
<li>
<p>invoke the rule with all variables bound, as a predicate check</p>
</li>
<li>
<p>any combination of variable bindings between these two extremes</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Often, complete flexibility in binding is exactly what you want. But in this case, the author of the rule has a specific intent:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>?max</code> is a <em>required</em> input, as nothing inside the rule knows how to manufacture a <code>?max</code></p>
</li>
<li>
<p><code>?a</code> is an intended input (this rule is about artists)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Rules can specify required vars in a list as the first element after the rule name. The rule head above can thus be rewritten as</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(short-track [?a ?max] ?t ?len)</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now the <code>?a</code> and <code>?max</code> variables are required. Datomic will not invoke a rule until required variables are bound, and will throw an exception if they cannot be bound.</p>
</div>
</div>
<div class="sect2">
<h3 id="_optimization_of_range_predicates">Optimization of Range Predicates</h3>
<div class="paragraph">
<p>Datomic now better leverages indexes to lookup range predicates (=, &#8656;, &gt;=, &lt;, and &gt;) where one argument is bound at the start of the query. For example, in the following query</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">[:find (count ?artist) .
 :in $ ?max-year
 :where [?artist :artist/startYear ?year]
 [(&lt; ?year ?max-year)]]</code></pre>
</div>
</div>
<div class="paragraph">
<p>Datomic will see that <code>?max-year</code> is bound, and use the AVET index on <code>:artist/startYear</code> to consider only datoms guaranteed to match the predicate. This can result in substantial speedups and reduced memory usage for queries that substantially limit results via range predicates.</p>
</div>
</div>
<div class="sect2">
<h3 id="_summary">Summary</h3>
<div class="paragraph">
<p>Taken together, the new capabilities above add substantial expressive power and performance to Datomic Datalog. Get the full details <a href="https://docs.datomic.com/query/query.html">in the docs</a>, and happy querying!</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Pull API</title>
      <link>https://blog.datomic.com/2014/10/datomic-pull.html</link>
      <pubDate>Tue, 28 Oct 2014 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2014/10/datomic-pull.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Datomic&#8217;s new Pull API is a declarative way to make hierarchical selections of information about entities. You supply a pattern to specify which attributes of the entity (and nested entities) you want to pull, and <code>db.pull</code> returns a map for each entity.</p>
</div>
<div class="sect3">
<h4 id="_pull_api_vs_entity_api">Pull API vs. Entity API</h4>
<div class="paragraph">
<p>The Pull API has two important advantages over the existing <a href="https://docs.datomic.com/reference/entities.html">Entity API</a>:</p>
</div>
<div class="paragraph">
<p>Pull uses a declarative, data-driven spec, whereas Entity encourages building results via code. Data-driven specs are easier to build, compose, transmit and store. Pull patterns are smaller than entity code that does the same job, and can be easier to understand and maintain.</p>
</div>
<div class="paragraph">
<p>Pull API results match standard collection interfaces (e.g. Java maps) in programming languages, where Entity results do not. This eliminates the need for an additional allocation/transformation step per entity.</p>
</div>

</div>
<div class="sect3">
<h4 id="_wildcards">Wildcards</h4>
<div class="paragraph">
<p>A pull pattern is a list of attribute specifications. If you want all attributes, you can use the wildcard (*) specification along with an <a href="https://docs.datomic.com/schema/identity.html#entity-identifiers">entity identifier</a>. (In the examples below, entity identifiers such as <code>led-zeppelin</code> are variables defined in the complete code examples in <a href="https://github.com/Datomic/day-of-datomic/blob/master/tutorial/pull.clj">Clojure</a> and <a href="https://github.com/Datomic/datomic-java-examples/blob/master/src/java/datomic/samples/Pull.java">Java</a>.)</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; Clojure API
(d/pull db '[*] led-zeppelin)</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">;; Java API
db.pull("[*]", ledZeppelin)</code></pre>
</div>
</div>
<div class="paragraph">
<p>A pull result is a map per entity, shown here in <a href="https://github.com/edn-format/edn">edn</a>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; result
{:artist/sortName "Led Zeppelin",
 :artist/name "Led Zeppelin",
 :artist/type {:db/id 17592186045746},
 :artist/country {:db/id 17592186045576},
 :artist/gid #uuid "678d88b2-87b0-403b-b63d-5da7465aecc3",
 :artist/endDay 25,
 :artist/startYear 1968,
 :artist/endMonth 9,
 :artist/endYear 1980,
 :db/id 17592186050305}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_attributes">Attributes</h4>
<div class="paragraph">
<p>You can also specify the attributes you want explicitly, as with <code>:artist/name</code> and <code>:artist/gid</code> below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; pattern
[:artist/name :artist/gid]

;; input
led-zeppelin

;; result
{:artist/gid #uuid "678d88b2-87b0-403b-b63d-5da7465aecc3",
 :artist/name "Led Zeppelin"}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The underscore prefix reverses the direction of an attribute, so <code>:artist/_country</code> pulls all the artists for a particular country:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; pattern
[:artist/_country]

;; input
greatBritain

;; result
{:artist/_country [{:db/id 17592186045751}
 {:db/id 17592186045755}
 ...]}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_components">Components</h4>
<div class="paragraph">
<p>Datomic component attributes are pulled recursively by default, so the <code>:release/media</code> pattern below automatically returns a release&#8217;s tracks as well:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; pattern
[:release/media]

;; input
darkSideOfTheMoon

;; result
 {:release/media
 [{:db/id 17592186121277,
 :medium/format {:db/id 17592186045741},
 :medium/position 1,
 :medium/trackCount 10,
 :medium/tracks
 [{:db/id 17592186121278,
 :track/duration 68346,
 :track/name "Speak to Me",
 :track/position 1,
 :track/artists [{:db/id 17592186046909}]}
 {:db/id 17592186121279,
 :track/duration 168720,
 :track/name "Breathe",
 :track/position 2,
 :track/artists [{:db/id 17592186046909}]}
 {:db/id 17592186121280,
 :track/duration 230600,
 :track/name "On the Run",
 :track/position 3,
 :track/artists [{:db/id 17592186046909}]}
 ...]}]}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_map_specifications">Map Specifications</h4>
<div class="paragraph">
<p>Instead of just an attribute name, you can use a nested map specification to pull related entities. The pattern below pulls the <code>:db/id</code> and <code>:artist/name</code> of each artist:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; pattern
[:track/name {:track/artists [:db/id :artist/name]}]

;; input
ghostRiders

;; result
{:track/artists [{:db/id 17592186048186, :artist/name "Bob Dylan"}
 {:db/id 17592186049854, :artist/name "George Harrison"}],
 :track/name "Ghost Riders in the Sky"}</code></pre>
</div>
</div>
<div class="paragraph">
<p>And of course everything nests arbitrarily, in case you need the release&#8217;s medium&#8217;s track&#8217;s names and artists:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure"> ;; pattern
[{:release/media
 [{:medium/tracks
 [:track/name {:track/artists [:artist/name]}]}]}]

;; input
concertForBanglaDesh

;; result
 [{:medium/tracks
 [{:track/artists
 [{:artist/name "Ravi Shankar"} {:artist/name "George Harrison"}],
 :track/name "George Harrison / Ravi Shankar Introduction"}
 {:track/artists [{:artist/name "Ravi Shankar"}],
 :track/name "Bangla Dhun"}]}
 {:medium/tracks
 [{:track/artists [{:artist/name "George Harrison"}],
 :track/name "Wah-Wah"}
 {:track/artists [{:artist/name "George Harrison"}],
 :track/name "My Sweet Lord"}
 {:track/artists [{:artist/name "George Harrison"}],
 :track/name "Awaiting on You All"}
 {:track/artists [{:artist/name "Billy Preston"}],
 :track/name "That's the Way God Planned It"}]
 ...]}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_try_it_out">Try It Out</h4>
<div class="paragraph">
<p>The Pull API has many other capabilities not shown here. See the <a href="https://docs.datomic.com/query/query-pull.html">full docs</a> for <a href="https://docs.datomic.com/query/query-pull.html#default-expressions">defaults</a>, <a href="https://docs.datomic.com/query/query-pull.html#limit-expressions">limits</a>, <a href="https://docs.datomic.com/query/query-pull.html#recursive-specifications">bounded and unbounded recursion</a>, and more. Or check out the examples in <a href="https://github.com/Datomic/day-of-datomic/blob/master/tutorial/pull.clj">Clojure</a> and <a href="https://github.com/Datomic/datomic-java-examples/blob/master/src/java/datomic/samples/Pull.java">Java</a>.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Stuff Happens: Fixing Bad Data in Datomic</title>
      <link>https://blog.datomic.com/2014/08/stuff-happens-fixing-bad-data-in-datomic.html</link>
      <pubDate>Tue, 19 Aug 2014 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2014/08/stuff-happens-fixing-bad-data-in-datomic.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Oops! You just put some bad data in your system, and now you need a way to clean it up. In this article, we look at how to recover from data errors. Along the way, we will explore how Datomic models time.</p>
</div>
<div class="sect1">
<h2 id="_a_motivating_example">A Motivating Example</h2>
<div class="sectionbody">
<div class="paragraph">
<p>ACME Co. buys, sells, and processes things. Unfortunately, their circa-2003 web interface is not a shining example of UI/UX design. Befuddled by all the modal screens, managers regularly put bad data into the system.</p>
</div>
<div class="paragraph">
<p>In fact, manager Steve just accidentally created an inventory record showing that ACME now has 999 Tribbles. This is ridiculous, since everyone knows that the CEO refuses to deal in Tribbles, citing "a bad experience". In a rather excited voice, Steve says "Quick, please delete the last entry added to the system!"</p>
</div>
<div class="paragraph">
<p>As is so often the case, job one is to carefully interpret a stakeholder&#8217;s request. In particular, the words "delete", "last", and "entry" all warrant careful consideration.</p>
</div>

<div class="sect2">
<h3 id="_what_delete_means">What "Delete" Means</h3>
<div class="paragraph">
<p>Let&#8217;s start with "delete". At first glance, one might think that Steve wants us to do our best to "unhappen" his mistake. But upon reflection, that isn&#8217;t such a good idea. The database is a live system, and someone may have used the bad data to make decisions. If so, then simply <em>excising</em> the mistake will just lead to more confusion later. What if, during the few minutes Tribbles were in the inventory, we sold a Tribble? Or, more subtly, what if we moved our widget inventory to a different warehouse to make room for the nonexistent Tribbles?</p>
</div>
<div class="paragraph">
<p>Databases need to remember the history of their data, even (and perhaps especially) when the data is later discovered to be bad. An easy analogy to drive home the point is source control. Source control systems act as a simple database for code. When a bug happens, you care very much about which versions of the code manifest the bug.</p>
</div>
<div class="paragraph">
<p>So rather than deleting the Tribbles, we want something more like a "reverting commit" in source control; that is, to record that we no longer believe that we have (or in fact ever had) Tribbles, but that during a specific time window we mistakenly believed we had 999 Tribbles.</p>
</div>
</div>
<div class="sect2">
<h3 id="_what_last_means">What "Last" Means</h3>
<div class="paragraph">
<p>Next, let us consider the temporal word "last". Happily, ACID databases have a unit of time ordering: transactions. Datomic goes a step further with <em>reified transactions</em>, i.e. transactions that you can manipulate as first-class objects in the system. In such a system, you might indeed be able to say "Treat the last transaction as a data entry error and record a reverting transaction."</p>
</div>
<div class="paragraph">
<p>We still need to be careful, though, about what we mean by "last". Again, the inventory system is a live system, so the last transaction is a moving target. It would be dangerous and incorrect to blindly revert the last transaction, without making sure that Steve&#8217;s erroneous transaction is still the last one. Generally, we will want a way to review recent transactions, and then narrow down by some other criteria, e.g. the id for Tribbles.</p>
</div>
</div>
<div class="sect2">
<h3 id="_what_entry_means">What "Entry" Means</h3>
<div class="paragraph">
<p>Finally, let&#8217;s consider what constitutes an "entry". This is a domain concept, and might or might not correspond directly to a row in a table, or to a document, or whatever metaphor your database encourages. Mistakes can have arbitrary and irregular shapes. When correcting errors, we will want to have <em>granular</em> representations of data, so that we can precisely target the error without also having to modify correct data nearby.</p>
</div>
<div class="paragraph">
<p>Putting that all together, we need to:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>locate the precise problem among recent transaction data</p>
</li>
<li>
<p>create a transaction that reverts the bad information&#8230;&#8203;</p>
</li>
<li>
<p>&#8230;&#8203;without forgetting that the problem happened.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Let&#8217;s take this to code.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_retraction_in_code">Retraction in Code</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The code examples that follow are in Groovy rather than Java for concision&#8217;s sake. You can download the <a href="https://github.com/Datomic/datomic-groovy-examples/blob/1a5eccf0840f804d2a002a869f3b0b7ae96b7691/src/main/CorrectingErrors.groovy">sample code</a> from the <a href="https://github.com/Datomic/datomic-groovy-examples">Datomic Groovy Examples</a> repository.</p>
</div>
<div class="paragraph">
<p>Let&#8217;s begin with our erroneous transaction, creating a record for Tribbles with a unique id, description, and count:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">addTribbles = [[':db/id': tempid(':db.part/user'),
 ':item/id': '0042-TRBL',
 ':item/description': 'Tribble: a low maintenance pet.',
 ':item/count': 999]];
conn.transact(addTribbles).get();</code></pre>
</div>
</div>
<div class="sect2">
<h3 id="_finding_the_problem">Finding the Problem</h3>
<div class="paragraph">
<p>OK, the clock is ticking: we have bad data in the system. How can we look to see what we have? For many everyday uses, you want an associative (entity) view of data. Depending on your language and tools, an entity representation may be a strongly-typed object or a mere dictionary, and may be generated by hand or automated through an ORM. Regardless, an associative representation allows you to navigate from keys to values.</p>
</div>
<div class="paragraph">
<p>In Datomic, you can pass a <a href="https://docs.datomic.com/schema/identity.html#lookup-refs">lookup ref</a> (a pair containing a unique key and its value) to the <a href="https://docs.datomic.com/reference/entities.html">entity API</a> to get an entity:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">db = conn.db();
db.entity([':item/id', '0042-TRBL']);</code></pre>
</div>
</div>
<div class="paragraph">
<p>Entities imply a three way relation of entity / attribute / value. The entity is implicit in object identity, the attributes are keys (or getter methods), and the values are looked up via the attributes. Given an entity, you can call <a href="https://docs.datomic.com/javadoc/datomic/Entity.html#keySet()">keySet</a> to find its keys, or <a href="https://docs.datomic.com/javadoc/datomic/Entity.html#get(java.lang.Object)">get</a> to lookup the value at a particular key.</p>
</div>
<div class="paragraph">
<p>What entities do <em>not</em> tell you is how, when, or why data got into the system. One way to improve this is to think in terms of a broader relation. Instead of a 3-tuple of entity / attribute / value, Datomic uses a <em>datom</em>: a 5-tuple of entity / attribute / value / transaction / added. The fourth slot, <em>transaction</em>, references an entity that records the time the transaction was added to the system (plus possibly other facts about the transaction). The fifth slot, <em>added</em>, is a boolean that records whether the datom is being asserted (true) or retracted (false).</p>
</div>
<div class="paragraph">
<p>Datoms allow you to see (and annotate) the complete history of entities in your system. For example, the following Datalog query will return all the facts about Tribbles.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">q('''[:find ?aname ?v ?tx ?added
 :in $ ?e
 :where [?e ?a ?v ?tx ?added]
 [?a :db/ident ?aname]]''',
 db,
 [':item/id', '0042-TRBL']);</code></pre>
</div>
</div>
<div class="paragraph">
<p>We aren&#8217;t going to cover Datalog syntax here, but will point out a few things in passing:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>variables begin with <code><strong>?</strong></code></p>
</li>
<li>
<p>data patterns in the <code><strong>:where</strong></code> clause are specified in Datom order, i.e. entity, attribute, value, transaction, added</p>
</li>
<li>
<p>the <code><strong>:in</strong></code> clause binds parameters, so this query binds <code><strong>?e</strong></code> to find only facts about id <code>0042-TRBL</code>, Tribbles.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The query results, shown below, show us that all facts about Tribbles were added in the same transaction, 13194139534315.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Attribute</th>
<th class="tableblock halign-left valign-top">Value</th>
<th class="tableblock halign-left valign-top">Transaction</th>
<th class="tableblock halign-left valign-top">Added?</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/description</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Tribble: a low maintenance pet.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/id</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0042-TRBL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/count</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">999</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_searching_the_log">Searching The Log</h3>
<div class="paragraph">
<p>In the query above, we knew that the problem was Tribbles, and could use that to look up the information. Let&#8217;s imagine instead that we know only that the problem just happened. To ask a "when" question, you can explicitly access the <a href="https://docs.datomic.com/reference/log.html">database log</a>, which is a time index. In Datomic, the <em>basisT</em> of a database identifies the most recent transaction, and can be passed to the <code><strong>tx-data</strong></code> function inside a query to access the log and return datoms from a specific transaction. The following query shows the entire transaction that added the Tribbles.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">log = conn.log();
q('''[:find ?e ?aname ?v ?tx ?added
 :in $ ?log ?tx
 :where [(tx-data ?log ?tx) [[?e ?a ?v _ ?added]]]
 [?a :db/ident ?aname]]''',
 db,
 log,
 db.basisT());</code></pre>
</div>
</div>
<div class="paragraph">
<p>This query shows us not only the troubled Tribble datoms, but also information about the transaction that added them:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;">
<col style="width: 20%;">
<col style="width: 20%;">
<col style="width: 20%;">
<col style="width: 20%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Entity</th>
<th class="tableblock halign-left valign-top">Attribute</th>
<th class="tableblock halign-left valign-top">Value</th>
<th class="tableblock halign-left valign-top">Transaction</th>
<th class="tableblock halign-left valign-top">Added?</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">17592186045420</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/description</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Tribble: a low maintenance pet.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">17592186045420</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/id</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0042-TRBL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">17592186045420</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/count</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">999</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">:db/txInstant</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">2014-05-19T17:20:48.200-00:00</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The combination of granular datoms, the powerful Datalog query language, and direct access to the database log make it possible to find out everything about a data error. Now let&#8217;s fix the error, without losing history of the event.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_fixing_the_problem">Fixing the Problem</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The transaction that added the Tribbles actually said three things about Tribbles:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Tribbles exist</p>
</li>
<li>
<p>Tribbles have a description</p>
</li>
<li>
<p>we have 999 Tribbles</p>
</li>
</ul>
</div>
<div class="sect2">
<h3 id="_simple_retraction">Simple Retraction</h3>
<div class="paragraph">
<p>Let&#8217;s presume that it is innocuous to acknowledge the existence of Tribbles. Thus we can make a very granular correction, refuting only the absurd notion that we have Tribbles in inventory:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">errDoc = 'Error correction entry. We do not sell Tribbles.';
weDontSellTribbles =
[[':db/add', [':item/id', '0042-TRBL'], ':item/count', 0],
 [':db/add', tempid(':db.part/tx'), ':db/doc', errDoc]];
conn.transact(weDontSellTribbles).get();</code></pre>
</div>
</div>
<div class="paragraph">
<p>This correction adds two facts to the database:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>an assertion that we have, in fact, zero Tribbles</p>
</li>
<li>
<p>a documentation string on the transaction entity (<code>:db.part/tx</code>) explaining the correction</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_retraction_with_provenance">Retraction with Provenance</h3>
<div class="paragraph">
<p>Another possibility is that ACME does not want even to acknowledge the existence of Tribbles. So we need to retract the entire Tribble entity. Also, ACME has a policy of recording a manager&#8217;s identity along with an error correction. Here, then is a transaction that removes the Tribble entity entirely, and credits John Doe with the removal:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">retractTribbles =
[[':db.fn/retractEntity', [':item/id', '0042-TRBL']],
 [':db/add',
 tempid(':db.part/tx'),
 ':corrected/by', [':manager/email', 'jdoe@example.com']]];
conn.transact(retractTribbles).get();</code></pre>
</div>
</div>
<div class="paragraph">
<p><code>:db.fn/retractEntity</code> is a built-in database function that expands to datoms retracting every fact about an entity. <code>:correction/by</code> is an attribute specific to the <a href="https://github.com/Datomic/datomic-groovy-examples/blob/1a5eccf0840f804d2a002a869f3b0b7ae96b7691/resources/main/inventory.edn">schema of this database</a>, and is an example of how you can extend the information model to capture provenance information for transactions.</p>
</div>
</div>
<div class="sect2">
<h3 id="_you_can_go_back_again">You <em>Can</em> Go Back Again</h3>
<div class="paragraph">
<p>Now that Tribbles have been retracted entirely, they will be invisible to queries or entity calls against the database. But while they are gone, they are not forgotten. The history view of a database shows not just the present, but the entire past of the database. The following query shows the complete history of Tribbles in the database:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">hist = conn.db().history();
q('''[:find ?aname ?v ?tx ?added
 :in $ ?e
 :where [?e ?a ?v ?tx ?added]
 [?a :db/ident ?aname]]''',
 hist,
 [':item/id', '0042-TRBL']);</code></pre>
</div>
</div>
<div class="paragraph">
<p>As you can see below, this history includes the original problem transaction, the partial correction, and the complete removal of the entity.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Attribute</th>
<th class="tableblock halign-left valign-top">Value</th>
<th class="tableblock halign-left valign-top">Transaction</th>
<th class="tableblock halign-left valign-top">Added?</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/description</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Tribble: a low maintenance pet.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/id</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0042-TRBL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/count</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">999</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534315</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/count</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">999</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534317</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/count</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534317</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/id</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0042-TRBL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534318</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/description</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Tribble: a low maintenance pet.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534318</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">:item/count</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">13194139534318</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_where_are_we">Where Are We?</h3>
<div class="paragraph">
<p>We have now accomplished everything we set out to do:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>We used Datalog queries to precisely locate problem data, both by recency and by identifying key.</p>
</li>
<li>
<p>We took advantage of the granularity of datoms to create transactions that precisely retracted problem data.</p>
</li>
<li>
<p>We used reified transactions and the history view of the database to remember what went wrong, and how it was fixed.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Time is a fundamental dimension of information systems, and it cannot be easily retrofitted to systems that only support traditional row or document views of information. In particular, note that the queries above take a database (not a connection) argument. That database can be filtered with <a href="https://docs.datomic.com/javadoc/datomic/Database.html#history()">history</a>, <a href="https://docs.datomic.com/javadoc/datomic/Database.html#asOf(java.lang.Object)">asOf</a>, or <a href="https://docs.datomic.com/javadoc/datomic/Database.html#since(java.lang.Object)">since</a> to pass different windows of time to the same query. With a time model, "point-in-time" or "range-of-time" queries can use the same logic as "now" queries.</p>
</div>
<div class="paragraph">
<p>That all sounds pretty good. So, should all of your information systems build upon a time model?</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_modeling_time_concerns_and_tradeoffs">Modeling Time: Concerns and Tradeoffs</h2>
<div class="sectionbody">
<div class="paragraph">
<p>There are a number of issues to consider when modeling time in an information system; we will consider a few of the most common issues here.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>What are the performance concerns when keeping historical data?</p>
</li>
<li>
<p>Is there some data for which historical information is irrelevant or counterproductive?</p>
</li>
<li>
<p>But I <em>really</em> want to delete something!</p>
</li>
<li>
<p>I understand the importance of remembering past mistakes, but I want "clean" history, too.</p>
</li>
</ol>
</div>
<div class="sect2">
<h3 id="_performance_concerns">Performance Concerns</h3>
<div class="paragraph">
<p>Data structures that preserve past values of themselves are called <em>persistent.</em> A common first reaction to persistence in databases is "Can I actually afford to remember everything?" You may remember that a similar objection was raised when Git first became popular: "Can I really afford to keep the entire history of projects on my laptop?"</p>
</div>
<div class="paragraph">
<p>It is important to understand that history can be managed so that queries are "pay as you go". If you do not use history in a particular query, that query will perform just as well as if you were not storing history. Modern immutable databases such as Datomic make such optimizations.</p>
</div>
<div class="paragraph">
<p>With that out of the way, the other major concern is storage cost. For many systems, particularly transactional systems of record, the balance of this argument is usually in favor of keeping everything. If the information is worth recording at all, it is worth the cost of keeping it.</p>
</div>
<div class="paragraph">
<p>But some information has little value, and does not warrant history.</p>
</div>
</div>
<div class="sect2">
<h3 id="_not_everything_needs_history">Not Everything Needs History</h3>
<div class="paragraph">
<p>At the other extreme from systems of record you have high-volume data that has little information value per fact, but some utility in the aggregate. A good example of this is a hit counter on web site. While you might be interested to know that 10,000 people are visiting every hour, you probably don&#8217;t care to know the exact time for each counter increment.</p>
</div>
<div class="paragraph">
<p>Counters and other high churn, low point-in-time value storage does not benefit from history.</p>
</div>
</div>
<div class="sect2">
<h3 id="_excision">Excision</h3>
<div class="paragraph">
<p>There are a few scenarios where systems really do need to deliberately and irrevocably lose data. The most common such scenario is a legal requirement to remove information from a system for privacy or intellectual property reasons.</p>
</div>
<div class="paragraph">
<p>For such situations, Datomic provides <em><a href="https://docs.datomic.com/operation/excision.html">excision</a></em>, which permanently removes facts from the system. This feature should <em>never</em> be used to fix mistakes. To continue the source code analogy, this would be the equivalent of saying "Wow, that was a really dodgy bug, let&#8217;s corrupt source control so it looks like the bug never happened."</p>
</div>
</div>
<div class="sect2">
<h3 id="_clean_history">Clean History</h3>
<div class="paragraph">
<p>We have been talking about history as "what we believed in the past". But from there one might aspire to know "what was <em>true</em> in the past", or at least "what we <em>now</em> think was true at some point of time in the past.</p>
</div>
<div class="paragraph">
<p>The ability to annotate transactions provides a path to multiple notions of history. For example, you could define a <code>:tx/mistake</code> attribute, and use it to mark transactions that later prove to be erroneous. You could then query against a <a href="https://docs.datomic.com/javadoc/datomic/Database.html#filter(datomic.Database.Predicate)">filtered</a> database that does not see those transactions at all.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_wrapping_up">Wrapping Up</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Stuff happens, and information systems will acquire bad data. <em>Never delete your mistakes</em>. Use fine grained information such as datoms to pinpoint your errors, and use retraction and reified transactions in a persistent database such as Datomic to correct errors while preserving history.</p>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Adaptive Indexing</title>
      <link>https://blog.datomic.com/2014/03/datomic-adaptive-indexing.html</link>
      <pubDate>Mon, 24 Mar 2014 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2014/03/datomic-adaptive-indexing.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>We are pleased to announce today new <strong>Adaptive Indexing</strong> support for <a href="https://www.datomic.com/">Datomic</a>. Adaptive indexing involves both a new index format and algorithm for how indexes are maintained. It should prove especially beneficial to those with large databases, high write loads, or large imports.</p>
</div>

<div class="sect3">
<h4 id="_some_of_the_benefits">Some of the benefits:</h4>
<div class="ulist">
<ul>
<li>
<p>Reduced work to be done per indexing job</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>There will be fewer index segments written, which should take less time and/or allow for reduced write provisioning when using DynamoDB.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Reduced memory requirements</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>We have revised downwards both the default and recommended thresholds for memory-index-threshold (to 32m) and memory-index-max (to 512m), for all workloads. This will also reduce memory pressure on peers, which are similarly configured. In addition, indexing itself uses less memory and has better GC characteristics. You will not approach memory-index-max except during imports and bulk loads.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Simpler configuration and less variability</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>You should rarely need to diverge from the defaults, and generally can use the same configuration for imports and ongoing production.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Sustainable import rates independent of db size</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>You will see indexing job times flatten out even as your db size grows linearly, as there is a sub-linear worst-case relationship between db size and indexing job size All of this is done while minimizing the amount of merging done during reads.</p>
</div>
<div class="paragraph">
<p><strong>TL;DR - much better and more predictable performance, using fewer resources.</strong></p>
</div>
<div class="paragraph">
<p>We expect adaptive indexing to make a tangible difference to most customers, and look forward to your feedback. Be sure to read the <a href="https://docs.datomic.com/release-notices.html#adaptive-indexing">release notices</a> for important details.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Lookup Refs</title>
      <link>https://blog.datomic.com/2014/02/datomic-lookup-refs.html</link>
      <pubDate>Thu, 13 Feb 2014 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2014/02/datomic-lookup-refs.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p><a href="https://www.datomic.com/">Datomic</a>'s new <a href="https://docs.datomic.com/schema/identity.html#lookup-refs">lookup refs</a> provide an easy way to identify entities by domain unique identifiers.</p>
</div>
<div class="sect2">
<h3 id="_rationale">Rationale</h3>
<div class="paragraph">
<p>Datomic supports several approaches to <a href="https://docs.datomic.com/schema/identity.html">identity</a>, including internal identifiers (entity IDs that are unique within a database) and external identifiers (domain attributes that are designated to be <code><strong>:db.unique/identity</strong></code>). Lookup refs provide a concise data representation that accords to external ids the powers of internal ids, and can be used interchangeably with internal ids in the Datomic API. This is powerful, since often, e.g. in the front-end of a system or during imports, you already have the external ids in hand. With lookups refs you can often avoid having to incorporate a lookup in application code since the lookup will be done implicitly when resolving the lookup ref (thus the name).</p>
</div>

</div>
<div class="sect2">
<h3 id="_implementation">Implementation</h3>
<div class="paragraph">
<p>A <strong>lookup ref</strong> is simply a java.util.List containing two elements: a unique attribute and a value for that attribute. Encoded in <a href="https://github.com/edn-format/edn">edn</a>, a Lookup ref looks like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">[:org/email "info@datomic.com"]</code></pre>
</div>
</div>
<div class="paragraph">
<p>Lookup refs can be used in the <a href="https://docs.datomic.com/javadoc/datomic/Entity.html">entity API</a>, or in any of the database <a href="https://docs.datomic.com/javadoc/datomic/Database.html">index APIs</a>. For example, the following code retrieves an entity:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">// Groovy
db.entity([':org/email', 'info@datomic.com'])</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; Clojure
(d/entity db [:org/email "info@datomic.com"])</code></pre>
</div>
</div>
<div class="paragraph">
<p>Lookup refs can also be used to refer to existing entities in transaction data. This allows updating transactions to specify <code>:db/id</code> directly instead of using a dummy upsert, as shown below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">;; edn transaction data, using temp :db/id and dummy upsert
[{:db/id #db/id[:db.part/user]
 :org/email "info@datomic.com",
 :org/favoriteColor :blue}]

;; edn transaction data, using lookup ref
[{:db/id [:org/email "info@datomic.com"],
 :org/favoriteColor :blue}]</code></pre>
</div>
</div>
<div class="paragraph">
<p>Similarly, they can be used in transactions to build ref relationships.</p>
</div>
<div class="paragraph">
<p>We expect that <strong>lookup refs</strong> will expedite a wide variety of use cases, including imports, interactive exploration, and client application development.</p>
</div>
<div class="paragraph">
<p>We look forward to your feedback.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Schema Alteration</title>
      <link>https://blog.datomic.com/2014/01/schema-alteration.html</link>
      <pubDate>Thu, 23 Jan 2014 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2014/01/schema-alteration.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p><a href="https://www.datomic.com/">Datomic</a> is a database that has flexible, minimal schema. Starting with version 0.9.4470, available <a href="https://www.datomic.com/get-datomic.html">here</a>, we have added the ability to alter existing schema attributes after they are first defined. You can alter schema to</p>
</div>

<div class="ulist">
<ul>
<li>
<p>rename attributes</p>
</li>
<li>
<p>rename your own programmatic identities (uses of <code>:db/ident</code>)</p>
</li>
<li>
<p>add or remove indexes</p>
</li>
<li>
<p>add or remove uniqueness constraints</p>
</li>
<li>
<p>change attribute cardinality</p>
</li>
<li>
<p>change whether history is retained for an attribute</p>
</li>
<li>
<p>change whether an attribute is treated as a component</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Schema alterations use the same transaction API as all other transactions, just as schema installation does. All schema alterations can be performed while a database is online, without requiring database downtime. Most schema changes are effective immediately, at the end of the transaction. There is one exception: adding an index requires a background job to build the new index. You can use the new <a href="https://docs.datomic.com/javadoc/datomic/Connection.html#syncSchema-long-">syncSchema API</a> for detecting when a schema change is available.</p>
</div>
<div class="paragraph">
<p>When renaming an attribute or identity, you can continue to use the old name as long as you haven&#8217;t repurposed it. This allows for incremental application updating.</p>
</div>
<div class="paragraph">
<p>See the schema alteration <a href="https://docs.datomic.com/on-prem/schema/schema.html#schema-alteration">docs</a> for the details.</p>
</div>
<div class="paragraph">
<p>Schema alteration has been our most requested enhancement. We hope you find it useful and look forward to your feedback.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic 2013 Recap</title>
      <link>https://blog.datomic.com/2014/01/datomic-2013-recap.html</link>
      <pubDate>Wed, 8 Jan 2014 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2014/01/datomic-2013-recap.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>2013 was a great year for <a href="https://www.datomic.com/">Datomic</a>. The value of a flexible information model and immutable data have proven themselves time and again. Customers have built a variety of powerful systems, taking advantage of</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.datomic.com/transactions/acid.html">ACID</a> transactions</p>
</li>
<li>
<p>pluggable SQL/NoSQL/cloud storage</p>
</li>
<li>
<p>complete access to the history of information</p>
</li>
<li>
<p>the Datalog <a href="https://docs.datomic.com/query/query-data-reference.html">query language</a></p>
</li>
<li>
<p>elastic read scalability</p>
</li>
<li>
<p>a granular information model</p>
</li>
</ul>
</div>

<div class="paragraph">
<p>Over the course of the year, we produced over 40 Datomic releases. The API has been remarkably stable: Our commitment to a strong architecture has allowed us to focus on adding features and fleshing out the vision, without the churn of revisiting past decisions.</p>
</div>
<div class="paragraph">
<p>A major new feature is the <a href="https://blog.datomic.com/2013/10/datomic-console.html">Datomic Console</a>, a graphical UI for exploring Datomic databases. The console provides a great visual introduction to the Datomic information model. It supports exploring schema, building and executing queries, navigating entities, examining transaction history, and walking raw indexes.</p>
</div>
<div class="paragraph">
<p>We made several API additions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://blog.datomic.com/2013/05/excision.html">Excision</a>, a sound model (and API) for permanent removal of data, with auditability.</p>
</li>
<li>
<p>The <a href="https://docs.datomic.com/reference/log.html">log</a> API provides the ability to access the log, which is more properly viewed as a time index.</p>
</li>
<li>
<p>The <a href="https://docs.datomic.com/javadoc/datomic/Database.html#seekDatoms(java.lang.Object,java.lang.Object&#8230;&#8203;)">seekDatoms</a> and <a href="https://docs.datomic.com/javadoc/datomic/Database.html#entidAt(java.lang.Object,java.lang.Object)">entidAt</a> APIs provide advanced capability for accessing Datomic&#8217;s indexes, augmenting the datoms API.</p>
</li>
<li>
<p>The <a href="https://blog.datomic.com/2013/06/sync.html">sync</a> API allows multiple processes to coordinate around points in time-of-record, or relative to local process time.</p>
</li>
<li>
<p>Transaction <a href="https://blog.datomic.com/2013/06/component-entities.html">map expansion</a> automates the creation of arbitrarily nested data.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>We also made a number of operational improvements:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>We added <a href="https://blog.datomic.com/2013/12/cassandra-support.html">Cassandra</a> and to the list of supported storage, in addition to the existing options of DynamoDB, SQL, filesystem, CouchBase, Infinispan, and Riak.</p>
</li>
<li>
<p>The <a href="https://blog.datomic.com/2013/11/datomic-pro-starter-edition.html">Starter Edition</a> of the Datomic Pro license makes all storages available, for free.</p>
</li>
<li>
<p>We have added a number of new <a href="https://docs.datomic.com/operation/monitoring.html">CloudWatch metrics</a>, and a pluggable metrics API for integration with other systems.</p>
</li>
<li>
<p>The <a href="https://blog.datomic.com/2013/07/datomic-musicbrainz-sample-database.html">MusicBrainz sample database</a> is a great dataset for exploring Datomic.</p>
</li>
<li>
<p>We continue to track AWS best practices, now supporting <a href="https://blog.datomic.com/2013/11/using-iam-roles-with-datomic-on-aws.html">IAM roles</a> for distributing credentials and DynamoDB local for testing.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>We are looking forward to an equally exciting 2014. We will be delivering a number of new features requested by users, plus a few big surprises.</p>
</div>
<div class="paragraph">
<p>Many thanks to our customers and early adopters for your support and feedback.</p>
</div>
<div class="paragraph">
<p>Happy New Year!</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Cassandra Support</title>
      <link>https://blog.datomic.com/2013/12/cassandra-support.html</link>
      <pubDate>Wed, 18 Dec 2013 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2013/12/cassandra-support.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>We are pleased to announce alpha support for Cassandra as a storage service for <a href="https://www.datomic.com/">Datomic</a>, now available in version 0.9.4384.</p>
</div>
<div class="paragraph">
<p>Cassandra is an elastically scalable, distributed, redundant and highly-available column store. Recent versions of Cassandra added support for compare-and-swap operations via lightweight transactions using an implementation of the Paxos protocol. Datomic leverages this mechanism to manage a small number of keys per database that require coordinated access, while the bulk of a database&#8217;s content is written as immutable data to a quorum of replicas in the cluster.</p>
</div>

<div class="paragraph">
<p>Cassandra support requires a minimum Apache Cassandra 2.0.2 or newer, or equivalent. Native CQL protocol support must be enabled. Cross-data center deployments are not supported. Cassandra internal security is supported, but optional.</p>
</div>
<div class="paragraph">
<p>This release represents preliminary support based on requests from users. We are very interested in feedback.</p>
</div>
<div class="paragraph">
<p>For instructions on configuring Cassandra for use with Datomic, see <a href="https://docs.datomic.com/operation/storage.html">Setting Up Storage Services</a>.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Using IAM Roles with Datomic on AWS</title>
      <link>https://blog.datomic.com/2013/11/using-iam-roles-with-datomic-on-aws.html</link>
      <pubDate>Mon, 25 Nov 2013 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2013/11/using-iam-roles-with-datomic-on-aws.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>With today&#8217;s <a href="https://www.datomic.com/">Datomic</a> release, you can use <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html">IAM</a> roles to manage permissions when running in AWS.</p>
</div>
<div class="sect2">
<h3 id="_motivation">Motivation</h3>
<div class="paragraph">
<p>Datomic&#8217;s AWS support has been designed according to the <a href="https://en.wikipedia.org/wiki/Principle_of_least_privilege">principle of least privilege</a>. When running in AWS, a Datomic transactor or peer needs only the minimum permissions necessary to communicate with various AWS services. These permissions are documented in <a href="https://docs.datomic.com/operation/storage.html">Setting Up Storage Services</a>.</p>
</div>
<div class="paragraph">
<p>But you still need some way to <em>install</em> these minimal permissions on ephemeral virtual hardware. Early versions of AWS left this problem to the developer. Solutions were tedious and ad hoc, but more important they were risky. Leaving every application developer the task of <em>passing</em> credentials around is a recipe for credentials <em>lying</em> around in a hundred different places (or even checked into source code repositories.)</p>
</div>

<div class="paragraph">
<p>IAM roles provide a generic solution to this problem. From the <a href="https://aws.amazon.com/iam/faqs/#iam_role_management_anchor">FAQ</a>: "An IAM role allows you to delegate access, with defined permissions, to trusted entities <em>without having to share long term access keys</em>" (emphasis added). From a developer perspective, IAM roles get credentials out of your application code.</p>
</div>
</div>
<div class="sect2">
<h3 id="_implementation">Implementation</h3>
<div class="paragraph">
<p>Starting with version 0.9.4314, Datomic supports IAM roles as the default mechanism for conveying credentials in AWS. What does this mean for developers?</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>If you are configuring Datomic for the first time, the <a href="https://docs.datomic.com/operation/storage.html">setup instructions</a> will secure peers and transactors using IAM roles.</p>
</li>
<li>
<p>If you have an existing Datomic installation and want to upgrade to roles, <a href="http://docs.datomic.com/legacy/migrate-to-roles.html">Migrating to IAM Roles</a> will walk you through the process.</p>
</li>
<li>
<p>Using explicit credentials in transactor properties and in connection URIs is deprecated, but will continue to work. <em>Your existing deployments will not break.</em></p>
</li>
</ol>
</div>
<div class="paragraph">
<p>IAM roles make your application both easier to manage and more secure. Use them.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Pro Starter Edition</title>
      <link>https://blog.datomic.com/2013/11/datomic-pro-starter-edition.html</link>
      <pubDate>Fri, 8 Nov 2013 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2013/11/datomic-pro-starter-edition.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic is Free</a>. The pricing and licensing information in this blog post is outdated.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>We are happy to announce today the release of <strong>Datomic Pro Starter Edition,</strong> enabling the use of <a href="https://www.datomic.com/">Datomic</a> for small production deployments <strong><em>at no cost</em></strong>.</p>
</div>
<div class="paragraph">
<p>Datomic Pro Starter Edition features most benefits of Datomic Pro:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Support for <strong>all storages</strong></p>
</li>
<li>
<p>A perpetual license with 12 months of updates included</p>
</li>
<li>
<p>Support for the full Datomic programming model</p>
</li>
<li>
<p><a href="https://blog.datomic.com/2013/10/datomic-console.html">Datomic Console</a> included with download</p>
</li>
</ul>
</div>

<div class="paragraph">
<p>Datomic Pro Starter Edition features community support, and does not include:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>High Availability transactor support</p>
</li>
<li>
<p>Integrated memcached</p>
</li>
<li>
<p>Running more than 3 processes (2 peers + transactor)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>To get started, register and download <a href="https://my.datomic.com/starter">Datomic Pro Starter Edition</a>.</p>
</div>
<div class="paragraph">
<p>Datomic Pro Starter Edition lets your team build a fully operational system and deploy to production with no additional steps or costs.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Console</title>
      <link>https://blog.datomic.com/2013/10/datomic-console.html</link>
      <pubDate>Tue, 29 Oct 2013 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2013/10/datomic-console.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>[<strong>Update:</strong> Watch the <a href="https://www.youtube.com/watch?v=jyuBnl0XQ6s">intro video</a>.]</p>
</div>
<div class="paragraph">
<p>The Datomic Console is a graphical UI for exploring <a href="https://www.datomic.com/">Datomic</a> databases.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-uAPGoXiZKlE/UmkRQBdnNOI/AAAAAAAAAGU/qf43oTJk9IE/s640/console-window.png" alt="The Datomic Console interface: a schema tree and data sources on the left; Query, Entities, Transactions, and Indexes tabs with a query builder and results pane on the right.">
</div>
</div>
<div class="paragraph">
<p>It supports exploring schema, building and executing queries, navigating entities, examining transaction history, and walking raw indexes. The Datomic Console is included in <a href="http://downloads.datomic.com/pro.html">Datomic Pro</a>, and is available as a <a href="https://my.datomic.com/downloads/console">separate download</a> for Datomic Free users.</p>
</div>

<div class="sect2">
<h3 id="_exploring_schema">Exploring Schema</h3>
<div class="paragraph">
<p>The upper left corner of the console displays a tree view of the attributes defined for the current database.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-eKlDbaQTvZg/UmkRG5HRBGI/AAAAAAAAAGM/zjR9fnld5OM/s320/console-schema.png" alt="The Schema panel: a tree of artist attributes (country, gid, name, and so on), with the name attribute expanded to show its cardinality, value type, and other properties.">
</div>
</div>
</div>
<div class="sect2">
<h3 id="_query">Query</h3>
<div class="paragraph">
<p>The Query tab provides two synchronized views of queries: a graphical builder, and the equivalent textual representation.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-jx-ZmKw6o6M/UmkRa0anJzI/AAAAAAAAAGc/X9y81NzL5gE/s640/console-query.png" alt="The Query tab showing a graphical query builder (Find, In, and Where clauses) beside the equivalent textual Datalog query.">
</div>
</div>
<div class="paragraph">
<p>You can see the results of a query in the Dataset pane on the lower right.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-k9q_HGN725g/UmkRhUaddxI/AAAAAAAAAGk/pKhYFFeynGI/s640/console-dataset.png" alt="The Data Set results pane listing query results in two columns — entity references paired with their documentation strings.">
</div>
</div>
</div>
<div class="sect2">
<h3 id="_entities">Entities</h3>
<div class="paragraph">
<p>The Entities tab provides a tree view of an entity, plus the ability to drill in to related entities.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-LX6uHUQV6DA/UmkRnb9C-OI/AAAAAAAAAGs/Sou-qlBDuNA/s640/console-entities.png" alt="The Entities tab showing one artist entity (Foo Fighters) — its attributes such as country, name, and start year, plus expandable reverse references to related releases and tracks.">
</div>
</div>
</div>
<div class="sect2">
<h3 id="_transactions">Transactions</h3>
<div class="paragraph">
<p>The Transactions tab provides a graphical view of the history of your database at scales ranging from days down to seconds.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-H2qQ5agqrXM/UmkRr0HPP1I/AAAAAAAAAG0/VAFT0lVFLqc/s640/console-transactions.png" alt="The Transactions tab: a bar chart of transaction counts per minute for one hour, with controls to zoom in and out over time.">
</div>
</div>
<div class="paragraph">
<p>When you zoom in, the specific datoms in a transaction are displayed in the dataset pane.</p>
</div>
</div>
<div class="sect2">
<h3 id="_indexes">Indexes</h3>
<div class="paragraph">
<p>The Indexes tab allows you to browse ranges within a Datomic index, displaying results in the dataset pane.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-Jn4Qe6YafhA/UmkR0RiHGwI/AAAAAAAAAG8/6v13UogZVM0/s640/console-indexes.png" alt="The Indexes tab: form fields for browsing the AVET index by attribute and value to retrieve matching datoms or an index range.">
</div>
</div>
</div>
<div class="sect2">
<h3 id="_and_more">And More</h3>
<div class="paragraph">
<p>This post only scratches the surface, see the <a href="http://docs.datomic.com/console.html">full docs</a> for more details. You can save arbitrary datasets, giving them a name for reuse in subsequent queries. And, of course, you can use Datomic&#8217;s time features to work with as-of, since, and historical views of your data.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>The Transaction Report Queue</title>
      <link>https://blog.datomic.com/2013/10/the-transaction-report-queue.html</link>
      <pubDate>Fri, 11 Oct 2013 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2013/10/the-transaction-report-queue.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Summary: Functional databases such as Datomic eliminate the burden of deciding what information a downstream observer needs. Just give 'em everything, lazily.</p>
</div>
<div class="sect2">
<h3 id="_the_transaction_report_queue">The Transaction Report Queue</h3>
<div class="paragraph">
<p>In Datomic, you can monitor all transactions. Any peer process in the system can request a <a href="https://docs.datomic.com/javadoc/datomic/Connection.html#txReportQueue--">transaction report queue</a> of every transaction against a particular database.</p>
</div>
<div class="paragraph">
<p><a href="https://github.com/Datomic/datomic-java-examples/blob/08f0baf2ac1846a425e746504532632b7dc6c707/src/java/datomic/samples/TxReportWatcher.java">TxReportWatcher</a> is a simple example of this. It watches a particular attribute in the database, and prints the entity id and value whenever a change to that attribute appears. The essence of the code is only a few lines of Java:</p>
</div>

<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">final BlockingQueue queue = conn.txReportQueue();

while (true) {
 final Map tx = queue.take();
 Collection results = q(byAttribute, tx.get(TX_DATA), attrid);
 for (Iterator it = results.iterator(); it.hasNext(); ) {
 printList(it.next());
 }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>There are several things to note here:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The Datomic query function <code>q</code> is used to query the transaction data, showing that the full power of the database query language is available while handling transaction events.</p>
</li>
<li>
<p>The <code>TX_DATA</code> map key points to all the data added to the database by this particular transaction.</p>
</li>
<li>
<p>Everything is made of generic data structures accessible from any JVM language: queues, collections, maps, and lists. (There is no ResultSet API.)</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_context_matters">Context Matters</h3>
<div class="paragraph">
<p>How much information does a transaction observer need in order to take useful action? An easy but naive answer is "just the `TX_DATA`".</p>
</div>
<div class="paragraph">
<p>But when you move past toy systems and blog examples, context matters. For example, when a user places an order in a system, you might want to take different actions based on</p>
</div>
<div class="ulist">
<ul>
<li>
<p>that user&#8217;s order history</p>
</li>
<li>
<p>the current inventory status</p>
</li>
<li>
<p>time limited promotions</p>
</li>
<li>
<p>that user&#8217;s relation to other users</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>It is impossible to anticipate in advance the context you might need. But if you don&#8217;t provide enough information, you will have to go back and ask for more. There are many risks here. The biggest risk is that such asking will introduce tighter coupling via the need for <em>coordination</em>, e.g. going back and asking questions of a database, questions that <em>must</em> be coordinated with the time of the event. Unnecessary coordination is a cause of complexity (and an enemy of scalability).</p>
</div>
<div class="paragraph">
<p>Is there another way? You bet! If you have a functional database, where points in time are immutable values, then you can make <em>the entire database</em> available. Datomic provides exactly this. In addition to the <code>TX_DATA</code> key, the <code>DB_AFTER</code> key points to the entire database as of the completion of the transaction. And the <code>DB_BEFORE</code> key points to the entire database <em>immediately before</em> the transaction started. Because both the "before" and "after" copies of the database are immutable values, no coordination with other processes is required, ever.</p>
</div>
</div>
<div class="sect2">
<h3 id="_a_common_misconception">A Common Misconception</h3>
<div class="paragraph">
<p>Developers often raise an objection to this approach: "Oh, I see, this approach is limited to tiny databases that can fit in memory and be passed around." Not at all. Because they are immutable, Datomic databases can be <em>lazily realized</em>, pulling into memory only the parts that are needed.</p>
</div>
<div class="paragraph">
<p>Moreover, Datomic&#8217;s indexes provide <em>leverage</em> over your data. Queries do not have to realize the entire database, they can use just the data needed. Datomic indexes provide leverage for "row", "column", "document", and "graph" access styles, so a wide variety of workloads are efficient. Different peers will "cache over" their working sets automatically, without you having to plan in advance which machine needs which data.</p>
</div>
</div>
<div class="sect2">
<h3 id="_composition_ftw">Composition FTW</h3>
<div class="paragraph">
<p>Datomic&#8217;s transaction report queue makes it possible for any peer to observe and respond to transactions, with complete access to all necessary context, and without any coordination with database writes. Transaction reports are a simple building block for scalable systems.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic MusicBrainz sample database</title>
      <link>https://blog.datomic.com/2013/07/datomic-musicbrainz-sample-database.html</link>
      <pubDate>Mon, 1 Jul 2013 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2013/07/datomic-musicbrainz-sample-database.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p><a href="https://musicbrainz.org/">MusicBrainz</a> is an open music encyclopedia that collects music metadata and makes it available to the public. We are pleased to release a <a href="https://github.com/Datomic/mbrainz-sample">sample project</a> that uses the MusicBrainz dataset to help people get familiar with using <a href="https://www.datomic.com/">Datomic</a>.</p>
</div>
<div class="paragraph">
<p>The MusicBrainz dataset makes a great example database for learning, evaluating, or testing Datomic for a couple of reasons:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>It deals with a domain with which nearly everyone is familiar</p>
</li>
<li>
<p>It is of decent size: 60,438 labels; 664,226 artists; 1,035,592 album releases; and 13,233,625 recorded tracks</p>
</li>
<li>
<p>It comprises a good number of entities, attributes, and relationships</p>
</li>
<li>
<p>It is fun to play with, query, and explore</p>
</li>
</ul>
</div>

<div class="sect1">
<h2 id="_schema">Schema</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The <a href="https://github.com/Datomic/mbrainz-sample/tree/master/schema.edn">mbrainz-sample schema</a> is an adaptation of a subset of the full <a href="https://musicbrainz.org/doc/MusicBrainz_Database/Schema">MusicBrainz schema</a>. We didn&#8217;t include some entities, and we made some simplifying assumptions and combined some entities. In particular:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>We omit any notion of <a href="https://musicbrainz.org/doc/Work">Work</a></p>
</li>
<li>
<p>We combine Track, Tracklist and <a href="https://musicbrainz.org/doc/Recording">Recording</a> into simply "track"</p>
</li>
<li>
<p>We renamed <a href="https://musicbrainz.org/doc/Release_Group">Release group</a> to "abstractRelease"</p>
</li>
</ul>
</div>
<div class="sect2">
<h3 id="_abstract_release_vs_release_vs_medium">Abstract Release vs. Release vs. Medium</h3>
<div class="paragraph">
<p>(Adapted from the MusicBrainz <a href="https://musicbrainz.org/doc/MusicBrainz_Database/Schema">schema docs</a>)</p>
</div>
<div class="paragraph">
<p>An "abstractRelease" is an abstract "album" entity (e.g. "The Wall" by Pink Floyd). A "release" is something you can buy in your music store (e.g. the 1984 US vinyl release of "The Wall" by Columbia, as opposed to the 2000 US CD release by Capitol Records).</p>
</div>
<div class="paragraph">
<p>Therefore, when you query for releases e.g. by name, you may see duplicate releases. To find just the "work of art" level album entity, query for abstractRelease.</p>
</div>
<div class="paragraph">
<p>The media are the physical components comprising a release (disks, CDs, tapes, cartridges, piano rolls). One medium will have several tracks, and the total tracks across all media represent the track list of the release.</p>
</div>
</div>
<div class="sect2">
<h3 id="_relationship_diagram">Relationship Diagram</h3>
<div class="imageblock">
<div class="content">
<img src="https://github.com/Datomic/mbrainz-sample/raw/master/relationships.png" alt="Entity-relationship diagram of the mbrainz schema: release references script, language, label, country, artist, abstractRelease, and medium; medium references track; track and abstractRelease reference artist; label and artist reference country. Each reference is labelled with its cardinality.">
</div>
</div>
</div>
<div class="sect2">
<h3 id="_entities">Entities</h3>
<div class="paragraph">
<p>For information about the individual entities and their attributes, please see the <a href="https://github.com/Datomic/mbrainz-sample/wiki/Schema">schema</a> page in the wiki, or the <a href="https://github.com/Datomic/mbrainz-sample/blob/master/schema.edn">EDN schema</a> itself.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_getting_started">Getting Started</h2>
<div class="sectionbody">
<div class="paragraph">
<p>First <a href="https://github.com/Datomic/mbrainz-sample#getting-datomic">get Datomic</a>, and start up a transactor.</p>
</div>
<div class="sect2">
<h3 id="_getting_the_data">Getting the Data</h3>
<div class="paragraph">
<p>Next download the <a href="http://s3.amazonaws.com/mbrainz/datomic-mbrainz-backup-20130611.tar">mbrainz backup</a>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre> # 2.8 GB, md5 4e7d254c77600e68e9dc71b1a2785c53
 wget http://s3.amazonaws.com/mbrainz/datomic-mbrainz-backup-20130611.tar</pre>
</div>
</div>
<div class="paragraph">
<p>and extract:</p>
</div>
<div class="listingblock">
<div class="content">
<pre> # this takes a while
 tar -xvf datomic-mbrainz-backup-20130611.tar</pre>
</div>
</div>
<div class="paragraph">
<p>Finally, <a href="https://docs.datomic.com/operation/backup.html">restore the backup</a>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre> # takes a while, but prints progress -- ~150,000 segments in restore
 bin/datomic restore-db file:datomic-mbrainz-backup-20130611 datomic:free://localhost:4334/mbrainz</pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_getting_the_code">Getting the Code</h3>
<div class="paragraph">
<p>Clone the <a href="https://github.com/Datomic/mbrainz-sample">git repo</a> somewhere convenient:</p>
</div>
<div class="listingblock">
<div class="content">
<pre> git clone git@github.com:Datomic/mbrainz-sample.git
 cd mbrainz-sample</pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_running_the_examples">Running the examples</h3>
<div class="sect3">
<h4 id="_from_java">From Java</h4>
<div class="paragraph">
<p>Fire up your favorite IDE, and configure it to use both the included <a href="https://github.com/Datomic/mbrainz-sample/blob/master/pom.xml">pom.xml</a> and the following Java options when running:</p>
</div>
<div class="listingblock">
<div class="content">
<pre> -Xmx2g -server</pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_from_clojure">From Clojure</h4>
<div class="paragraph">
<p>Start up a Clojure REPL:</p>
</div>
<div class="listingblock">
<div class="content">
<pre> # from the root of the mbrainz-sample repo
 lein repl</pre>
</div>
</div>
<div class="paragraph">
<p>Then <a href="https://github.com/Datomic/mbrainz-sample/wiki/Queries">connect to the database and run the queries</a>.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_thanks">Thanks</h2>
<div class="sectionbody">
<div class="paragraph">
<p>We would like to thank the MusicBrainz project for defining and compiling a great dataset, and for making it freely available.</p>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Component Entities</title>
      <link>https://blog.datomic.com/2013/06/component-entities.html</link>
      <pubDate>Wed, 19 Jun 2013 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2013/06/component-entities.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>This post demonstrates <a href="https://www.datomic.com/">Datomic</a>'s component entities, and highlights a new way to create components available in today&#8217;s release. You can follow along in the <a href="https://github.com/Datomic/datomic-groovy-examples/blob/master/src/main/Components.groovy">code</a> via the <a href="https://github.com/Datomic/datomic-groovy-examples">sample project</a>.</p>
</div>
<div class="paragraph">
<p>The code examples use Groovy, a JVM language that combines similarity to Java with concision. If you are a Java developer new to Groovy, you may want to read <a href="https://blog.datomic.com/2013/06/using-datomic-from-groovy-part-1.html">this</a> first.</p>
</div>

<div class="sect2">
<h3 id="_why_components">Why Components?</h3>
<div class="paragraph">
<p>In a database, some entities are their own identities, and others exist only as part of a larger parent entity. In Datomic, the latter entities are called <em>components</em>, and are reached from the parent via an attribute whose <a href="https://docs.datomic.com/schema/schema-reference.html">schema</a> includes <code>:db/isComponent true</code>.</p>
</div>
<div class="paragraph">
<p>As a familiar example, consider orders, line items, and products. Orders have references to line items, and those references are through a component attribute, since line items have no independent existence outside of an order. Line items, in turn, have references to products. References to products are <em>not</em> component references, because products exist regardless of whether or not they are part of any particular order.</p>
</div>
<div class="paragraph">
<p>The schema for a line item component reference looks like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">{:db/id #db/id[:db.part/db]
 :db/ident :order/lineItems
 :db/isComponent true
 :db/valueType :db.type/ref
 :db/cardinality :db.cardinality/many
 :db.install/_attribute :db.part/db}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Notice also that line items are <code>:db.cardinality/many</code>, since a single order can have many of them.</p>
</div>
<div class="paragraph">
<p>Component attributes gain three special abilities in Datomic:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>you can create components via nested maps in a transaction (new in <a href="http://downloads.datomic.com/free.html">0.8.4020</a>)</p>
</li>
<li>
<p>touching an entity recursively touches all its components</p>
</li>
<li>
<p><code>:db.fn/retractEntity</code> recursively deletes all its components</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Each of these abilities is demonstrated below.</p>
</div>
</div>
<div class="sect2">
<h3 id="_creating_components">Creating Components</h3>
<div class="paragraph">
<p>To demonstrate line item components, let&#8217;s create an order for some chocolate and whisky. First, here is a query for products <code>?e</code> matching a particular description <code>?v</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">productQuery = '''[:find ?e
 :in $ ?v
 :where [?e :product/description ?v]]''';</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now, we can query for the products we want to order:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">(chocolate, whisky) = ['Expensive Chocolate', 'Cheap Whisky'].collect {
 q(productQuery, conn.db(), it)[0][0];
}
===&gt; [17592186045454, 17592186045455]</code></pre>
</div>
</div>
<div class="paragraph">
<p>The statement above uses Groovy&#8217;s <a href="https://groovy-lang.org/semantics.html#multiple-assignment">multiple assignment</a> to assign chocolate to the first query result, and whisky to the second.</p>
</div>
<div class="paragraph">
<p>Now that we have some products, we can create an order with some line items. As of today&#8217;s release, you can do this via nested maps:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">order = [['order/lineItems': [['lineItem/product': chocolate,
 'lineItem/quantity': 1,
 'lineItem/price': 48.00],
 ['lineItem/product': whisky,
 'lineItem/quantity': 2,
 'lineItem/price': 38.00]],
 'db/id': tempid()]];</code></pre>
</div>
</div>
<div class="paragraph">
<p>The nested maps above expand into two subentities. Notice that you do not need to create a <a href="https://docs.datomic.com/javadoc/datomic/Peer.html#tempid(java.lang.Object)">tempid</a> for the nested line items&#8201;&#8212;&#8201;they will be auto-assigned tempids in the same partition as the parent order.</p>
</div>
<div class="paragraph">
<p>The order above is pure data (a list of maps). This greatly facilitates development, testing, and composition. When we are ready to put the data in the database, the transaction is as simple as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">conn.transact(order).get();</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_touching_components">Touching Components</h3>
<div class="paragraph">
<p>Now we can query to find the order we just created. To demonstrate that query can reach anywhere within your data, we will do a multiway join to find the order via product description:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">ordersByProductQuery = '''
[:find ?e
 :in $ ?productDesc
 :where [?e :order/lineItems ?item]
 [?item :lineItem/product ?prod]
 [?prod :product/description ?productDesc]]''';</code></pre>
</div>
</div>
<div class="paragraph">
<p>The query above joins</p>
</div>
<div class="ulist">
<ul>
<li>
<p>from the provided <code>productDesc</code> input to to the product entity <code>?prod</code></p>
</li>
<li>
<p>from <code>?prod</code> to the order item <code>?item</code></p>
</li>
<li>
<p>from <code>?item</code> to the order <code>?e</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>and returns <code>?e</code>.</p>
</div>
<div class="paragraph">
<p>We are going to immediately pass <code>?e</code> to datomic&#8217;s entity API, so let&#8217;s take a moment to create a Groovy <a href="https://groovy-lang.org/closures.html">closure</a> qe that automates query + get entity:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">qe = { query, db, Object[] more -&gt;
 db.entity(q(query, db, *more)[0][0])
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now we can find an order the includes chocolate:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">order = qe(ordersByProductQuery, db, 'Expensive Chocolate');</code></pre>
</div>
</div>
<div class="paragraph">
<p>Because the Datomic database is an immutable value in your own address space, entities can be lazily realized. When you first look at the order, you won&#8217;t see any attributes at all:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">===&gt; {:db/id 17592186045457}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The <a href="https://docs.datomic.com/on-prem/clojure/index.html#datomic.api/touch">touch</a> API will realize all the immediate attributes of the order, plus it will recursively realize any components:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">order.touch();
===&gt; {:order/lineItems #{{:lineItem/product #,
 :lineItem/price 38.00M,
 :lineItem/quantity 2,
 :db/id 17592186045459}
 {:lineItem/product #,
 :lineItem/price 48.00M,
 :lineItem/quantity 1,
 :db/id 17592186045458}},
 :db/id 17592186045457}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Notice that the line items are immediately realized, and you can see all their attributes. However, the products are <em>not</em> immediately realized, since they are not components. You can, of course, touch them yourself if you want.</p>
</div>
</div>
<div class="sect2">
<h3 id="_retracting_components">Retracting Components</h3>
<div class="paragraph">
<p>I am not as hungry or thirsty as I thought. Let&#8217;s retract that order, using Datomic&#8217;s <code>:db.fn/retractEntity</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">conn.transact([[":db.fn/retractEntity", order[":db/id"]]]).get();</code></pre>
</div>
</div>
<div class="paragraph">
<p>Retracting an entity will retract all its subcomponents, in this case the line items. To see that the line items are gone, we can count all the line items in our database:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">q('''[:find (count ?e)
 :where [?e :order/lineItems]]''',
 db);
===&gt; []</code></pre>
</div>
</div>
<div class="paragraph">
<p>References to non-components will not be retracted. The products are all still there:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">q('''[:find (count ?e)
 :where [?e :product/description]]''',
 db);
===&gt; [[2]]</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_conclusion">Conclusion</h3>
<div class="paragraph">
<p>Components allow you to create substantial trees of data with nested maps, and then treat the entire tree as a single unit for lifecycle management (particularly retraction). All nested items remain visible as first-class targets for query, so <em>the shape of your data at transaction time does not dictate the shape of your queries</em>. This is a key value proposition of Datomic when compared to row, column, or document stores.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Using Datomic from Groovy, Part 1: Everything is Data</title>
      <link>https://blog.datomic.com/2013/06/using-datomic-from-groovy-part-1.html</link>
      <pubDate>Wed, 12 Jun 2013 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2013/06/using-datomic-from-groovy-part-1.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>In this post, I will demonstrate transacting and querying against <a href="https://www.datomic.com/">Datomic</a> from Groovy. The examples shown here are based on the following schema, for a simple social news application:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-qUkSm8ZwVPs/UbeCD8Q4acI/AAAAAAAAAE0/I-cnU2l88j8/s320/day-of-datomic.png" alt="day of datomic">
</div>
</div>
<div class="paragraph">
<p>There are a number of more in-depth <a href="https://github.com/Datomic/datomic-groovy-examples/tree/master/src/main">samples</a> in the <a href="https://github.com/Datomic/datomic-groovy-examples">datomic-groovy-examples</a> project on Github.</p>
</div>

<div class="sect2">
<h3 id="_why_groovy">Why Groovy</h3>
<div class="paragraph">
<p>Groovy offers four key advantages for a Java programmer using Datomic:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Groovy provides interactive development through <code>groovysh</code>, the <a href="https://groovy-lang.org/groovyconsole.html">Groovy shell</a>. When combined with Datomic&#8217;s dynamic, data-driven style, this makes it easy to interactively develop code in real time. The source code for this post has a number of other examples designed for interactive study within the Groovy shell.</p>
</li>
<li>
<p>Groovy&#8217;s <a href="https://groovy-lang.org/groovy-dev-kit.html">collection literals</a> make it easy to see your data. Lists and maps are as easy as:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">aList = ['John', 'Doe'];
aMap = [firstName: 'John',
 lastName: 'Doe'];</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Groovy&#8217;s <a href="https://groovy-lang.org/closures.html">closures</a> make it easy to write functions, without the noise of single-method interfaces and anonymous inner classes. For instance, you could grab all the lastNames from a collection of maps</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">lastNames = people.collect { it['lastName'] }</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Of the popular expressive languages that target the JVM, Groovy&#8217;s syntax is most similar to Java&#8217;s.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_transactions">Transactions</h3>
<div class="paragraph">
<p>A Datomic <a href="https://docs.datomic.com/transactions/transaction-processing.html">transaction</a> takes a list of data to be added to the database, and returns a <a href="https://docs.datomic.com/javadoc/datomic/ListenableFuture.html">future</a> map describing the results. The simplest possible transaction is a list of one sublist that adds an atomic fact, or <em>datom</em>, to the database, using the following shape:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">conn.transact([[op, entityId, attributeName, value]]);</code></pre>
</div>
</div>
<div class="paragraph">
<p>The components above are:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>op</code> is a keyword naming the operation. <code>:db/add</code> adds a datom, and <code>:db/retract</code> retracts a datom.</p>
</li>
<li>
<p><code>entityId</code> is the numeric id of an entity. You can use <code><a href="https://docs.datomic.com/javadoc/datomic/Peer.html#tempid(java.lang.Object)">tempid</a></code> when creating a new entity.</p>
</li>
<li>
<p><code>attributeName</code> is a keyword naming an attribute.</p>
</li>
<li>
<p><code>value</code> is the value of an attribute. The <a href="https://docs.datomic.com/schema/schema-reference.html">allowed types</a> for an attribute include numerics, strings, dates, URIs, UUIDs, binaries, and references to other entities.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Keywords are names, prefixed with a colon, possibly with a leading namespace prefix separated by the slash char, e.g.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">:hereIsAnUnqualifiedName
:the.namespace.comes.before/theName</code></pre>
</div>
</div>
<div class="paragraph">
<p>Putting this all together, you might add a new user&#8217;s first name with:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">conn.transact([[':db/add', newUserId, ':user/firstName', 'John']]);</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you are adding multiple datoms about the same entity, you can use a map instead of a list, with the special keyword <code>:db/id</code> identifying the entity. For example, the following two transactions are equivalent:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">// create an entity with two attributes (map form)
conn.transact([[':db/id': newUserId,
 ':user/firstName': 'John',
 ':user/lastName': 'Doe']]);

// create an entity with two attributes (list form)
conn.transact([[':db/add' newUserId, ':user/firstName', 'John'],
 [':db/add' newUserId, ':user/lastName', 'Doe']]);</code></pre>
</div>
</div>
<div class="paragraph">
<p>Let&#8217;s look next at composing larger transactions out of smaller building blocks. You have already seen creating a user:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">newUser = [[':db/id': newUserId,
 ':user/email': 'john@example.com',
 ':user/firstName': 'John',
 ':user/lastName': 'Doe']];</code></pre>
</div>
</div>
<div class="paragraph">
<p>Notice that this time we did not call transact yet, instead we just stored data describing the user into <code>newUser</code>.</p>
</div>
<div class="paragraph">
<p>Now imagine that you have a collection of story ids in hand, and you want to create a new user who upvotes those stories. Groovy&#8217;s <a href="https://docs.groovy-lang.org/latest/html/groovy-jdk/java/util/Collection.html">collect</a> method iterates over a collection, transforming values using a closure with a default single parameter named it. We can use collect to build new assertions that refer to each story in a collection of <code>storyIds</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">upvoteStories = storyIds.collect {
 [':db/add', newUserId, ':user/upVotes', it]
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now we are ready to build a bigger transaction out of the pieces. Because transactions are made of data, we don&#8217;t need a special API for this. Groovy already has an API for concatenating lists, called <code>+</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">conn.transact(upvoteAllStories + newUser);</code></pre>
</div>
</div>
<div class="paragraph">
<p>Building Datomic transactions from data has many advantages over imperative or object-oriented approaches:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Composition is automatic, and requires no special API.</p>
</li>
<li>
<p>ACID transactionality is scoped to transaction calls, and does not require careful management across separate calls to the database.</p>
</li>
<li>
<p>Because they are data, Datomic transactions are flexible across system topology changes: they can be built offline for later use, serialized, and/or enqueued.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_query">Query</h3>
<div class="paragraph">
<p>The Datomic <a href="https://docs.datomic.com/javadoc/datomic/Peer.html#q(java.lang.Object,java.lang.Object&#8230;&#8203;)">query</a> API is named q, and it takes a query plus one or more inputs. The simple query below takes a query plus a single input, the database <code>db</code>, and returns the id of every entity in the system with an email address:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">q('''[:find ?e
 :where [?e :user/email]]''', db);</code></pre>
</div>
</div>
<div class="paragraph">
<p>Keyword constants in the <code>:where</code> clause constrain the results. Here, <code>:user/email</code> constrains results to only those entities possessing an email.</p>
</div>
<div class="paragraph">
<p>Symbols preceded by a question mark are <em>variables</em>, and will be populated by the query engine. The variable <code>?e</code> will match every entity id associated with an email.</p>
</div>
<div class="paragraph">
<p>A query always returns a set of lists, and the <code>:find</code> clause specifies the shape of lists to return. In this example, the lists are of size one since a single variable <code>?e</code> is specified by <code>:find</code>.</p>
</div>
<div class="paragraph">
<p>Note that the query argument to <code>q</code> is notionally a list. As a convenience, you can pass the query argument as either a list or (as shown here) as an <a href="https://github.com/edn-format/edn">edn</a> string literal.</p>
</div>
<div class="paragraph">
<p>The next query further constrains the result, to find a specific email address:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">q('''[:find ?e
 :in $ ?email
 :where [?e :user/email ?email]]''',
 db, 'editor@example.com');</code></pre>
</div>
</div>
<div class="paragraph">
<p>There are several things to see here. There are now two inputs to the query: the database itself, and the specific email <code>"<a href="mailto:editor@example.com">editor@example.com</a>"</code> we are looking for. Since there is more than one input, the inputs must be named by an <code>:in</code> clause. The <code>:in</code> clause names inputs in the order they appear:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><code>$</code> is Datomic shorthand for a single database input.</p>
</li>
<li>
<p><code>?email</code> is bound to the scalar <code>"<a href="mailto:editor@example.com">editor@example.com</a>"</code>.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Inputs need not be scalar. The shape <code>[?varname &#8230;&#8203;]</code> in an <code>:in</code> clause is called a <em>collection binding form</em>, and it binds a collection instead of a single value. The following query looks up two different users by email:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">q('''[:find ?e
 :in $ [?email ...]
 :where [?e :user/email ?email]]''',
 db, ['editor@example.com', 'stuarthalloway@datomic.com']);</code></pre>
</div>
</div>
<div class="paragraph">
<p>Another way to join is by having more than one constraint in a <code>:where</code> clause. Whenever a variable appears more than once, it must match the same set of values in all the locations that it appears. The following query joins through <code>?user</code> to find all the comments for a user:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-groovy hljs" data-lang="groovy">q('''[:find ?comment
 :in $ ?email
 :where [?user :user/email ?email]
 [?comment :comment/author ?user]]''',
 db, 'editor@example.com')</code></pre>
</div>
</div>
<div class="paragraph">
<p>We have only scratched the surface here. Datomic&#8217;s <a href="https://docs.datomic.com/query/query-data-reference.html">query</a> also supports rules, predicates, function calls, cross-database queries (with joins!), aggregates, and even queries against ordinary Java collections without a database. In fact, the <a href="https://en.wikipedia.org/wiki/Datalog">Datalog</a> query language used in Datomic supports a superset of the capabilities of the relational algebra that underpins SQL.</p>
</div>
</div>
<div class="sect2">
<h3 id="_conclusion">Conclusion</h3>
<div class="paragraph">
<p>In this installment, you have seen the powerful, compositional nature of programming with generic data. In Part 2, we will look at the database as a value, and explore the implications of having a lazy, immutable database inside your application process.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Sync</title>
      <link>https://blog.datomic.com/2013/06/sync.html</link>
      <pubDate>Mon, 3 Jun 2013 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2013/06/sync.html</guid>
      	<description>
        <![CDATA[
	<div class="sect2">
<h3 id="_background">Background</h3>
<div class="paragraph">
<p><a href="https://www.datomic.com/">Datomic</a>'s approach to updating peers uses a push model. Rather than have every read request route to the same server in order to get consistent data, data is stored immutably, and as soon as there is new information, all peers are notified. This completely eliminates polling any server. Thus, contrary to common presumption, when you ask the connection for the db value, there is no network communication involved: you are immediately given the local value of the db about which the connection was most recently informed.</p>
</div>
<div class="paragraph">
<p>Everyone sees a valid, consistent view. You can never see partial transactions, corruption/regression of timelines, causal anomalies etc. Datomic is always 'business rules' valid, and causally consistent.</p>
</div>

</div>
<div class="sect2">
<h3 id="_motivation">Motivation</h3>
<div class="paragraph">
<p>That does not mean that every peer sees the same thing simultaneously. Just as in the real world, it is never the case that everyone sees the same thing "at the same time" in a live distributed system. There is no inherent shared truth, as you might convey a message to me about X at the speed of light but I can only perceive X at the speed of sound. Thus, I know X is coming, but I might have to wait for it.</p>
</div>
<div class="paragraph">
<p>This means that some peer A might commit a transaction and tell B about it before B is informed via the normal channels. This is an interesting case, as it has to do with perception and propagation delays. It is not a question of consistency, it is a question of communication synchronization.</p>
</div>
<div class="paragraph">
<p>It comes up when you would like to read-your-own-writes via other peers (e.g. when a client hits different peer servers via a load balancer), and when there is out-of-band communication of writes (A tells B about its write before the transactor does).</p>
</div>
</div>
<div class="sect2">
<h3 id="_tools">Tools</h3>
<div class="paragraph">
<p>We&#8217;ve <a href="https://www.datomic.com/get-datomic.html">added</a> a new <strong><em>sync</em></strong> API to help you manage these situations.</p>
</div>
<div class="paragraph">
<p>The <a href="https://docs.datomic.com/javadoc/datomic/Connection.html#sync(long)">first form of <strong>sync</strong></a> takes a basis point (T). It returns a future that will be fulfilled with a version of the db that includes point T. <em>This does not cause any additional interaction with the transactor</em> - the future will be filled by the normal communication on the update channels. But it saves you from having to poll for arrival. Most often, you will already have the requested T, and the future will complete immediately. This is the preferred method to use if you have any ability to convey the basis T, either in the message from A to B, or e.g. in cookies as a client hits different peers using a load balancer. You can easily <a href="https://docs.datomic.com/javadoc/datomic/Database.html#basisT()">get the basis T</a> for any db value you have in hand.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-nRloyHZAP20/UayuwohuYBI/AAAAAAAAAK8/z6SlbJ0kb2Q/s1600/oob42.png" alt="Diagram: the transactor streams transactions to peers A and B; peer A tells peer B out-of-band &quot;I did something you care about at T=42&quot;, so peer B calls sync(42) to wait until transaction 42 arrives.">
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-ObD-XFzGRnA/UayvbDbcBAI/AAAAAAAAALQ/WIdFOhftQ48/s1600/lb42.png" alt="Diagram: a web tier behind a load balancer dispatches requests across peers A and B; peer A&#8217;s basis T=42 is carried through the load balancer so peer B can sync(42) and read those writes.">
</div>
</div>
<div class="paragraph">
<p>The <a href="https://docs.datomic.com/javadoc/datomic/Connection.html#sync()">second form of <strong>sync</strong></a> takes no arguments, and works via 'ping' of the transactor. It promises not to return until all transactions that have been acknowledged by the transactor at the time sync was called have arrived at this peer. Thus if A has successfully committed a transaction and told B about it, and B then calls <strong>sync()</strong>, the database returned by <strong>sync</strong> will include A&#8217;s transaction.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-Lfg9_eHl1Vg/Uayv616aR8I/AAAAAAAAALY/IA62Z_BW7MA/s1600/sync.png" alt="Diagram: peer B calls sync() with no argument, pinging the transactor; sync returns only once every transaction the transactor had acknowledged has arrived at peer B.">
</div>
</div>
</div>
<div class="sect2">
<h3 id="_conclusion">Conclusion</h3>
<div class="paragraph">
<p>While these synchronization tools are powerful, make sure you use them only when necessary. The Datomic <a href="https://docs.datomic.com/javadoc/datomic/Connection.html#db()">defaults</a> were designed to leverage the inherent parallelism possible given immutable, accretion-only semantics and distributed storage. Notifications to peers are sent at the same time as the acknowledgement to the peer submitting the transaction, and thus are as 'simultaneous' as network communication can be. The sync tools need only be utilized to enforce cross-peer causal relationships.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>A Whirlwind Tour of Datomic Query</title>
      <link>https://blog.datomic.com/2013/05/a-whirlwind-tour-of-datomic-query_16.html</link>
      <pubDate>Thu, 16 May 2013 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2013/05/a-whirlwind-tour-of-datomic-query_16.html</guid>
      	<description>
        <![CDATA[
	<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This tour is to help those new to Datomic understand Datomic&#8217;s built-in datalog by providing a simple domain and schema, and by walking through some use cases. For a more complete treatment of Datomic&#8217;s query capabilities, please take a look at the <a href="https://docs.datomic.com/query/query.html">documentation</a>.</p>
</div>

</div>
</div>
<div class="sect1">
<h2 id="_reading_the_code">Reading the Code</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To follow along in code, you can download Datomic Free Edition at <a href="http://downloads.datomic.com/free.html">http://downloads.datomic.com/free.html</a>, and the sample project at <a href="https://github.com/datomic/day-of-datomic">https://github.com/datomic/day-of-datomic</a>. The code examples should be executed interactively, in the order presented in the article, from a Clojure REPL. The complete code is in the <a href="https://github.com/Datomic/day-of-datomic/blob/9ff6f53bd2562bc49fc3f7c1b216103eb9705cce/tutorial/query_tour.clj">query_tour.clj file</a>. The <em>`&#8658;`</em> prefix indicates responses that is printed by the REPL. The use of ellipsis (<em>&#8230;&#8203;</em>) in output indicates that a larger result has been truncated for brevity.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_a_simple_schema">A Simple Schema</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The example queries that follow work against a simplified schema that you might use for a social news database, containing users, stories, and comments:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-q45Fo2EBeEE/UZUF5FVHWNI/AAAAAAAAAA0/8BzCsuLos58/s320/social-news-schema.png" alt="social news schema">
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_get_connected">Get Connected</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In order to get a database connection, you will need to <em>require</em> namespaces for the Datomic API and for the news application, then setup a sample database.</p>
</div>
<div class="sect2">
<h3 id="_listing_1_getting_connected">Listing 1: Getting Connected</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(require
 '[datomic.api :as d]
 '[datomic.samples.news :as news])

 (def uri "datomic:mem://news")
 (def conn (news/setup-sample-db-1 uri))</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_get_a_database_value">Get a Database Value</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The connection from the previous step is already populated with a schema and sample data, but before you query against it, you must get the current <strong>value</strong> of the database. Syntactically this is trival:</p>
</div>
<div class="sect2">
<h3 id="_listing_2_getting_a_database_value">Listing 2: Getting a Database Value</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(def db (d/db conn))</code></pre>
</div>
</div>
<div class="paragraph">
<p>While the syntax of this step is trivial, the semantic implications are deep. Datomic queries do not happen "over there" in some database process, they happen here, in your process&#8217;s memory space.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_a_first_query">A first query</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Users in the system are identified by a <em>:user/email</em> attribute. Lets find all of them:</p>
</div>
<div class="sect2">
<h3 id="_listing_3_finding_all_users">Listing 3: Finding All Users</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/q '[:find ?e
 :where [?e :user/email]]
 db)</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; #{[17592186045424] [17592186045425]}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The large integers are entity ids. Entity ids are auto-assigned, so you may not see the same values on your system. There are several things to note here:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>As query is the most commonly used function in Datomic, it has the terse name <em>d/q</em>.</p>
</li>
<li>
<p>The first argument is a query expression. The <em>:where</em> clause indicates what you want to find, "those entities <em>?e</em> that have a <em>:user/email</em> attribute." The <em>:find</em> clause tells which variables to return.</p>
</li>
<li>
<p>The second argument is the database value we obtained in the previous step.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_a_simple_join">A simple join</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Rather than finding all users, let&#8217;s query for a particular user. This requires joining two query inputs: the database value, and the email you are seeking:</p>
</div>
<div class="sect2">
<h3 id="_listing_4_finding_a_specific_user">Listing 4: Finding a Specific User</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/q '[:find ?e
 :in $ ?email
 :where [?e :user/email ?email]]
 db
 "editor@example.com")</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; #{[17592186045425]}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Notice that there are now three arguments to the query: the query expression plus the two inputs. Also, since there are two inputs, there is now an <em>:in</em> clause to name the inputs, in the order they appear, e.g. <em>$</em> binds the database, and <em>?email</em> binds "<a href="mailto:editor@example.com">editor@example.com</a>". Names starting with <em>$</em> name databases, and names starting with <em>?</em> name variables.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_a_database_join">A database join</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The previous join of a database to a single prebound variable may not even look like a join to you&#8201;&#8212;&#8201;in many databases this operation would be called a parameterized query. So let&#8217;s look at a more traditional join, that leverages indexes in the database to associate more than one "type" of entity. The following query will find all of the editor&#8217;s comments:</p>
</div>
<div class="sect2">
<h3 id="_listing_5_finding_a_users_comments">Listing 5: Finding a User&#8217;s Comments</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/q '[:find ?comment
 :in $ ?email
 :where [?user :user/email ?email]
 [?comment :comment/author ?user]]
 db
 "editor@example.com")</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; #{[17592186045451]
 [17592186045450]
 ... }</code></pre>
</div>
</div>
<div class="paragraph">
<p>Notice that the <em>:where</em> clause now has two data patterns: one associating users to their emails, and another associating comments to the user that authored them. Because the variable <em>?user</em> appears in both clauses, the joins on <em>?user</em>, finding only comments made by the editor.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_aggregates">Aggregates</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You can obtain aggregates by changing the <em>:find</em> clause to include an aggregating function. Instead of finding the editor&#8217;s comments, let&#8217;s just <em>count</em> them:</p>
</div>
<div class="sect2">
<h3 id="_listing_6_returning_an_aggregate">Listing 6: Returning an Aggregate</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/q '[:find (count ?comment)
 :in $ ?email
 :where [?user :user/email ?email]
 [?comment :comment/author ?user]]
 db
 "editor@example.com")</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; [[10]]</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_more_joins">More joins</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Queries can make many joins. The following query joins comments to their referents, and joins the referents to <em>:user/email</em> to find any comments that are about people:</p>
</div>
<div class="sect2">
<h3 id="_listing_7_multiple_joins">Listing 7: Multiple Joins</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/q '[:find (count ?comment)
 :where [?comment :comment/author]
 [?commentable :comments ?comment]
 [?commentable :user/email]]
 db)</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; []</code></pre>
</div>
</div>
<div class="paragraph">
<p>No results is good news, because you don&#8217;t want to let things get personal by allowing people to comment on other people.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_schema_aware_joins">Schema-aware joins</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You cannot comment on people, but what kinds of things <strong>can</strong> you comment on?</p>
</div>
<div class="paragraph">
<p>The three slots you have seen in data patterns so far are <em>entity</em>, <em>attribute</em>, and <em>value</em>. Up this point, the <em>entity</em> and <em>value</em> positions have typically been variables, but the <em>attribute</em> has always been constant.</p>
</div>
<div class="paragraph">
<p>That need not be the case. Here is a query that finds all the attributes of entities that have been commented on:</p>
</div>
<div class="sect2">
<h3 id="_listing_8_a_schema_query">Listing 8: A Schema Query</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/q '[:find ?attr-name
 :where [?ref :comments]
 [?ref ?attr]
 [?attr :db/ident ?attr-name]]
 db)</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; #{[:story/title]
 [:comment/body]
 [:story/url]
 [:comment/author]
 [:comments]}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Schema entities are ordinary entities, like any other data in the system. Rather then return their entity ids (<em>?attr</em> in the query above), you can join through <em>:db/ident</em> to find the programmatic identifiers that name each attribute. Judging from these attribute names, there are comments about stories and comments about other comments, exactly what you would expect given the schema.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_entities">Entities</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In client/server databases where query happens in another process, it is often critical to get the answer and all of its details in a single query. (If you spread the work across multiple steps, you run the risk of the data changing between steps, leading to inconsistent results.)</p>
</div>
<div class="paragraph">
<p>Since Datomic performs queries in-process, against an immutable database value, it is feasible to decompose the work of query into steps. One very decomposition is to use a query to <strong>find</strong> entities, and then to use Datomic&#8217;s entity API to navigate to the relevant details about those entities.</p>
</div>
<div class="paragraph">
<p>Let&#8217;s try it with the editor. First, use a query to find the editor&#8217;s entity id:</p>
</div>
<div class="sect2">
<h3 id="_listing_9_finding_an_entity_id">Listing 9: Finding an Entity ID</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(def editor-id (-&gt;&gt; (d/q '[:find ?e
 :in $ ?email
 :where [?e :user/email ?email]]
 db
 "editor@example.com")
 ffirst))</code></pre>
</div>
</div>
<div class="paragraph">
<p>Notice that the query returns only the <em>?e</em>, not any particular attribute values.</p>
</div>
<div class="paragraph">
<p>Now, you can call <em>d/entity</em>, passing the database value and the entity id to get the editor entity.</p>
</div>
</div>
<div class="sect2">
<h3 id="_listing_10_getting_an_entity">Listing 10: Getting an Entity</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(def editor (d/entity db editor-id))</code></pre>
</div>
</div>
<div class="paragraph">
<p>When you first look at an entity, it appears to be a mostly empty map:</p>
</div>
</div>
<div class="sect2">
<h3 id="_listing_11_a_lazy_entity">Listing 11: A Lazy Entity</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">editor</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; {:db/id 17592186045425}</code></pre>
</div>
</div>
<div class="paragraph">
<p>That is because entities are <strong>lazy</strong>. Their attribute values will appear once you ask for them:</p>
</div>
</div>
<div class="sect2">
<h3 id="_listing_12_requesting_an_attribute">Listing 12: Requesting an Attribute</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(:user/firstName editor)</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; "Edward"</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you are feeling more eager, you can <em>touch</em> an entity to immediately realize all of its attributes:</p>
</div>
</div>
<div class="sect2">
<h3 id="_listing_13_touching_an_entity">Listing 13: Touching an Entity</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/touch editor)
 =&gt; {:user/firstName "Edward",
 :user/lastName "Itor",
 :user/email "editor@example.com",
 :db/id 17592186045425}</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_are_entities_orm">Are Entities ORM?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>No. Entities are used for some of the same purposes that you might use an ORM, but their capabilities are quite different. Entities differ from ORM objects in that the conversion between raw datoms and entities is entirely a mechanical process. There is never any configuration, and relationships are always available and (lazily!) navigable.</p>
</div>
<div class="paragraph">
<p>Entities also differ from most ORM objects in that relationships can be navigated in either direction. In the previous code example, you saw how the <em>d/touch</em> method would automatically navigate all outbound relationships from an entity. However, you can also navigate <strong>inbound</strong> relationships, by following the convention of prefixing attribute names with an underscore. For example, a user&#8217;s comments happen to be modeled as a relationship from the comment to the editor. To reach these comments from the editor entity, you can navigate the <em>:comment/author</em> attribute backwards:</p>
</div>
<div class="sect2">
<h3 id="_listing_14_navigating_backwards">Listing 14: Navigating Backwards</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(-&gt; editor :comment/_author)</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; [{:db/id 17592186045441}
 {:db/id 17592186045443}
 ... ]</code></pre>
</div>
</div>
<div class="paragraph">
<p>This process can, of course, be extended as far as you like, e.g. the following example navigates to all the comments people have made on the editor&#8217;s comments:</p>
</div>
</div>
<div class="sect2">
<h3 id="_listing_15_navigating_deeper">Listing 15: Navigating Deeper</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(-&gt;&gt; editor :comment/_author (mapcat :comments))</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; ({:db/id 17592186045448}
 {:db/id 17592186045450}
 ...)</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_time_travel">Time travel</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Update-in-place databases can tell you about the present, but most businesses need also to know about the past. Datomic provides this, by allowing you to take a value of a database as of a certain point in time.</p>
</div>
<div class="paragraph">
<p>Given any datom, there are three time-related pieces of data you can request:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the transaction entity <em>tx</em> that created the datom</p>
</li>
<li>
<p>the relative time, <em>t</em> of the transaction</p>
</li>
<li>
<p>the clock time <em>:db/txInstant</em> of the transaction</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The transaction entity is available as a fourth optional component of any data pattern. The following query finds the transaction that set the current value for the editor&#8217;s first name:</p>
</div>
<div class="sect2">
<h3 id="_listing_16_querying_for_a_transaction">Listing 16: Querying for a Transaction</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(def txid (-&gt;&gt; (d/q '[:find ?tx
 :in $ ?e
 :where [?e :user/firstName _ ?tx]]
 db
 editor-id)
 ffirst))</code></pre>
</div>
</div>
<div class="paragraph">
<p>Given a transaction id, the <em>d/tx&#8594;t</em> function returns the system-relative time that the transaction happened.</p>
</div>
</div>
<div class="sect2">
<h3 id="_listing_17_converting_transaction_to_t">Listing 17: Converting Transaction to T</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/tx-&gt;t txid)
=&gt; 1023</code></pre>
</div>
</div>
<div class="paragraph">
<p>Relative time is useful for "happened-before" type questions, but sometimes you want to know the actual wall clock time. This is stored once per transaction, as the <em>:db/txInstant</em> property of the <strong>transaction</strong> entity:</p>
</div>
</div>
<div class="sect2">
<h3 id="_listing_18_getting_a_tx_instant">Listing 18: Getting a Tx Instant</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(-&gt; (d/entity (d/db conn) txid) :db/txInstant)</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; #inst "2013-02-20T16:27:11.788-00:00"</code></pre>
</div>
</div>
<div class="paragraph">
<p>Given a <em>t</em>, <em>tx</em>, or <em>txInstant</em> value, you can travel to that point in time with <em>d/as-of</em>. The example below goes back in time to before the point that the first name Edward was introduced, to see its past value:</p>
</div>
</div>
<div class="sect2">
<h3 id="_listing_19_going_back_in_time">Listing 19: Going Back in Time</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(def older-db (d/as-of db (dec txid)))</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(:user/firstName (d/entity older-db editor-id))</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; "Ed"</code></pre>
</div>
</div>
<div class="paragraph">
<p>The example above shows an <em>as-of</em> value of the database being used as an argument to <em>d/entity</em>, but <em>as-of</em> values can be used anyhere a current database value can be used, including as an argument to query.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_auditing">Auditing</h2>
<div class="sectionbody">
<div class="paragraph">
<p>While <em>as-of</em> is useful for looking at a moment in the past, you may also want to perform time-spanning queries. This is particularly true in audit scenarios, where you might want a complete history report of some value.</p>
</div>
<div class="paragraph">
<p>To perform such queries, you can use the <em>d/history</em> view of a database, which spans all of time. The following query shows the entire history of the editor&#8217;s <em>:user/firstName</em> attribute:</p>
</div>
<div class="sect2">
<h3 id="_listing_20_querying_across_all_time">Listing 20: Querying Across All Time</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(def hist (d/history db))

(-&gt;&gt; (d/q '[:find ?tx ?v ?op
 :in $ ?e ?attr
 :where [?e ?attr ?v ?tx ?op]]
 hist
 editor-id
 :user/firstName)
 (sort-by first))</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; ([13194139534319 "Ed" true]
 [13194139534335 "Ed" false]
 [13194139534335 "Edward" true])</code></pre>
</div>
</div>
<div class="paragraph">
<p>The optional fifth field in a <em>:where</em> data pattern, named <em>?op</em> in the example above, matches true if a datom is asserted, or false if it is being retracted.</p>
</div>
<div class="paragraph">
<p>Transaction 13194139534319 set the editor&#8217;s first name to "Ed", and transaction 13194139534335 set it to "Edward". The cardinality of <em>:user/firstName</em> is one, which means that the system will only permit one value of that attribute per entity at any given time. To enforce this constaint, Datomic will automatically retract past values where necessary. Thus the transaction that asserts "Edward" also includes a retraction for the previous value "Ed".</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_everything_is_data">Everything is Data</h2>
<div class="sectionbody">
<div class="paragraph">
<p>One of Datomic&#8217;s design goals is "put declarative power in the hands of developers." Having queries that run in your process goes a long way to meet this objective, but what if you have data that is not in a Datomic database?</p>
</div>
<div class="paragraph">
<p>Datomic&#8217;s query engine can run without a database, against arbitrary data structures in your application.</p>
</div>
<div class="paragraph">
<p>The following example shows the query you began with, this time running against a plain Java list in memory:</p>
</div>
<div class="sect2">
<h3 id="_listing_21_querying_plain_java_data">Listing 21: Querying Plain Java Data</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/q '[:find ?e
 :where [?e :user/email]]
 [[1 :user/email "jdoe@example.com"]
 [1 :user/firstName "John"]
 [2 :user/email "jane@example.com"]])</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">=&gt; #{[1] [2]}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The idea behind POJOs (plain old Java objects) is exactly right, and Datomic encourages you to take it one step further, to plain old lists and maps.</p>
</div>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Excision</title>
      <link>https://blog.datomic.com/2013/05/excision.html</link>
      <pubDate>Fri, 10 May 2013 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2013/05/excision.html</guid>
      	<description>
        <![CDATA[
	<div class="sect3">
<h4 id="_motivation">Motivation</h4>
<div class="paragraph">
<p>It is a key value proposition of <a href="https://www.datomic.com/">Datomic</a> that you can tell not only what you know, but how you came to know it. When you add a fact:</p>
</div>
<div class="paragraph">
<p><code>conn.transact(list(":db/add", 42, ":firstName", "John"));</code></p>
</div>
<div class="paragraph">
<p>Datomic does more than merely record that 42&#8217;s first name is "John". Each datom is also associated with a transaction entity, which records the moment (<code>:db/txInstant</code>) the datom was recorded.</p>
</div>

<div class="imageblock">
<div class="content">
<img src="/images/blog/-SYxu8mIXnzg/UY0c5w3uSqI/AAAAAAAAAEQ/Lwd_N_eUQjI/s1600/john.png" alt="Diagram: Two datoms make up entity 42: [add :firstName &quot;John&quot;] and [add :lastName &quot;Doe&quot;], both recorded in transaction 44, whose reified :db/txInstant is 8:00:00 on May 7 2013.">
</div>
</div>
<div class="paragraph">
<p>Given these <em>reified transactions</em>, it is possible to track the history of information. Let&#8217;s say John decides he prefers to go by "Jack":</p>
</div>
<div class="paragraph">
<p><code>conn.transact(list(":db/add", 42, ":firstName", "Jack"));</code></p>
</div>
<div class="paragraph">
<p>When you assert a new value for a cardinality-one attribute such as <code>:firstName</code>, Datomic will automatically retract any past value (cardinality-one means that you cannot have two first names simultaneously). So now the database looks like this:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-3o3HDodfIEU/UY0dDdfP8WI/AAAAAAAAAEY/YBfuUfGjzLM/s1600/jack.png" alt="Diagram: entity 42&#8217;s datoms after the rename — :firstName &quot;John&quot; and :lastName &quot;Doe&quot; added in transaction 44, then :firstName &quot;John&quot; retracted and &quot;Jack&quot; added in transaction 46. Transactions 44 and 46 carry :db/txInstant timestamps of 8:00:00 and 8:05:00 on May 7 2013.">
</div>
</div>
<div class="paragraph">
<p>Given this information model, it is easy to see that Datomic can support queries that tell you:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>what you know now</p>
</li>
<li>
<p>what you knew at some point in the past</p>
</li>
<li>
<p>how and when you came to know any particular datom</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>So far so good, but there is a fly in the ointment. In certain situations you may be forced to <em>excise</em> data, pulling it out root and branch and forgetting that you <em>ever</em> knew it. This may happen if you store data that must comply with privacy or IP laws, or you may have a regulatory requirement to keep records for seven years and then "shred" them. For these scenarios, Datomic provides excision.</p>
</div>
</div>
<div class="sect3">
<h4 id="_excision_in_datomic">Excision in Datomic</h4>
<div class="paragraph">
<p>You can request excision of data by transacting a new entity with the following attributes:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>:db/excise</code> is required, and refers to a <em>target</em> entity or attribute to be excised. Thus there are two scenarios - excise all or part of an entity, or excise some or all of the values of a particular attribute.</p>
</li>
<li>
<p><code>:db.excise/attrs</code> is an optional, cardinality-many, reference attribute that limits an excision to a set of attributes, useful only when the target of excise is an entity. (If <code>:db.excise/attrs</code> are not specified, then all matching attributes will be excised.)</p>
</li>
<li>
<p><code>:db.excise/beforeT</code> is an optional, long-valued attribute that limits an excision to only datoms whose t is before the specified <code>beforeT</code>, which may be a t or tx id. This can be used with entity or attribute targets.</p>
</li>
<li>
<p><code>:db.excise/before</code> is an optional, instant-valued attribute that limits an excision to only datoms whose transaction time is before the specified <code>before</code>. This can be used with entity or attribute targets.</p>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="_example_excising_specific_entities">Example: Excising Specific Entities</h4>
<div class="paragraph">
<p>To excise a specific entity, manufacture a new entity with a :db/excise attribute pointing to that entity&#8217;s id. For example, if user 42 requests that his personal data be removed from the system, the transaction data would be:</p>
</div>
<div class="paragraph">
<p><code>[{:db/id #db/id[db.part/user],</code>
` :db/excise 42}]`</p>
</div>
<div class="paragraph">
<p>Since <code>:db.excise/attrs</code> is not specified in the transaction data above, <em>all</em> datoms about entity 42 will be excised.</p>
</div>
</div>
<div class="sect3">
<h4 id="_example_excising_a_window_in_time">Example: Excising a Window in Time</h4>
<div class="paragraph">
<p>To excise old values of a particular attribute, you can create an excision for the attribute you want to eliminate, and then limit the excision using either <code>before</code> or <code>beforeT</code>. Imagine tracking application events that have users, categories, and details. Your application produces a ton of events, but you don&#8217;t care about the old ones. Here is a transaction that will excise all the pre-2012 events:</p>
</div>
<div class="paragraph">
<p>`  [{:db/id #db/id[db.part/user],`
`    :db/excise :event/user`
`    :db.excise/before #inst "2012"}`
`   {:db/id #db/id[db.part/user],`
`    :db/excise :event/category`
`    :db.excise/before #inst "2012"}`
`   {:db/id #db/id[db.part/user],`
`    :db/excise :event/description`
`    :db.excise/before #inst "2012"}]`</p>
</div>
</div>
<div class="sect3">
<h4 id="_remembering_that_you_forgot">Remembering <em>That</em> You Forgot</h4>
<div class="paragraph">
<p>It is a key value proposition of Datomic that you can tell not only what you know, but how you came to know it. This seems to be at odds with excision: if you remember what you forgot, then you didn&#8217;t really forget it!</p>
</div>
<div class="paragraph">
<p>You cannot remember <em>what</em> you forgot, but you can remember <em>that</em> you forgot. Excise attributes are ordinary attributes in the database, and you can query them. The following query would tell you if datoms about entity 42 have ever been excised:</p>
</div>
<div class="paragraph">
<p><code>[:find ?e :where [?e :db/excise 42]]</code></p>
</div>
<div class="paragraph">
<p>Once you find those entities, you can of course use the entity API to navigate to the specific attribute and before filters of the excisions.</p>
</div>
<div class="paragraph">
<p>Excise attributes are protected from excision, so you cannot erase your tracks. (Other important datoms such as schema are also protected, see the <a href="https://docs.datomic.com/operation/excision.html">documentation</a> for full details.)</p>
</div>
</div>
<div class="sect3">
<h4 id="_handle_with_care">Handle With Care</h4>
<div class="paragraph">
<p>Excision is different from any other operation in Datomic. While excision requests are transactions, excision itself is <em>not</em> transactional. Excision will happen on the next indexing job.</p>
</div>
<div class="paragraph">
<p>Excision is permanent and unrecoverable. Take a backup before performing significant excisions, and use excision only when your domain requires that you deliberately forget certain data.</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Riak and Couchbase Support</title>
      <link>https://blog.datomic.com/2012/11/riak-and-couchbase-support.html</link>
      <pubDate>Fri, 2 Nov 2012 00:00:00 +0100</pubDate>
      <guid isPermaLink="false">2012/11/riak-and-couchbase-support.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>We are pleased to announce today preliminary support for two new storage services for <a href="https://www.datomic.com/">Datomic</a>: Riak and Couchbase.</p>
</div>

<div class="paragraph">
<p><a href="https://riak.com/products/riak-overview/">Riak</a> is an elastically scalable, distributed, redundant and highly available key-value store in the Dynamo model. It is a great option for Datomic users who want to run such a system on their own premises (vs e.g. DynamoDB on AWS). Because Riak supports only eventual consistency at this time, a Datomic system running on Riak also utilizes Apache ZooKeeper, a highly-available coordination service. Datomic uses ZooKeeper for transactor failover coordination, and for the handful of keys per database that need to be updated with <a href="https://en.wikipedia.org/wiki/Compare-and-swap">CAS</a>. The bulk of the data is kept in Riak, immutably, and leverages all of Riak&#8217;s redundancy and availability characteristics.</p>
</div>
<div class="paragraph">
<p><a href="http://www.couchbase.com/couchbase-server/overview">Couchbase</a> is an elastically scalable, distributed and redundant document store. Like Riak, it supports redundant storage. Unlike Riak, it does offer consistency and CAS, trading off for a more conventional availability model, with either manual or automatic failover.</p>
</div>
<div class="paragraph">
<p>Both solutions are backed with commercial support offerings from the people who make them.</p>
</div>
<div class="paragraph">
<p>With all three services (Riak, ZooKeeper, Couchbase), Datomic can run on an existing installation alongside other applications without conflict. Thus you can combine your use of Datomic with other uses of the storages, at which they excel. We consider this hybrid use to be highly appealing in practice, as different parts of your applications have different requirements.</p>
</div>
<div class="paragraph">
<p>As always, you can backup and restore to/from these storages and any other, and switch your application from one storage to another with a change to a different URI.</p>
</div>
<div class="paragraph">
<p>This makes the set of Datomic storages:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In-process memory</p>
</li>
<li>
<p>Transactor-local dev/free mode</p>
</li>
<li>
<p>SQL</p>
</li>
<li>
<p>DynamoDB</p>
</li>
<li>
<p>Riak</p>
</li>
<li>
<p>Couchbase</p>
</li>
<li>
<p>Infinispan</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>We are very excited about these new options, which greatly expand your choices, especially for non-cloud deployments. Each storage represents different tradeoffs, but what is important is that the choices are yours to make, as you decide what best fits your business and technical requirements.</p>
</div>
<div class="paragraph">
<p>We look forward to your feedback as we fine tune these integrations for production use.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>codeq</title>
      <link>https://blog.datomic.com/2012/10/codeq.html</link>
      <pubDate>Wed, 10 Oct 2012 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2012/10/codeq.html</guid>
      	<description>
        <![CDATA[
	<div class="sect2">
<h3 id="_backstory">Backstory</h3>
<div class="paragraph">
<p>Programmer Sally: "<em>So, what are you going to do today Bob?</em>"</p>
</div>
<div class="paragraph">
<p>Programmer Bob: "<em>I&#8217;m not happy with the file baz.clj residing in my/ns. So I&#8217;m going to go to line 96 and change 2 to 42. I&#8217;ve been thinking about deleting line 124. If I have time, I&#8217;m also going to insert some text I&#8217;ve been working on at line 64.</em>"</p>
</div>
<div class="paragraph">
<p>Programmer Sally: <em>(what&#8217;s wrong with Bob?)</em></p>
</div>
</div>
<div class="sect2">
<h3 id="_short_story">Short Story</h3>
<div class="paragraph">
<p><a href="https://github.com/Datomic/codeq#codeq"><strong>codeq</strong></a> ('co-deck') is a little application that imports your Git repositories into a <a href="https://www.datomic.com/">Datomic</a> database, then performs language-aware analysis on them, extending the Git model down from the file to the code quantum (<strong><em>codeq</em></strong>) level, and up across repos. By doing so, <strong>codeq</strong> allows you to:</p>
</div>

<div class="ulist">
<ul>
<li>
<p>Track change at the program unit level (e.g. function and method definitions)</p>
</li>
<li>
<p>Query your programs and libraries declaratively, with the same cognitive units and names you use while programming</p>
</li>
<li>
<p>Query across repos</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The resulting database is highly programmable, and can serve as infrastructure for editors, IDEs, code browsing, analysis and documentation tools.</p>
</div>
<div class="paragraph">
<p><strong>codeq</strong> is open source (EPL), and <a href="https://github.com/Datomic/codeq">on github</a>. It works with <a href="https://www.datomic.com/get-datomic.html">Datomic Free</a>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_long_story">Long Story</h3>
<div class="paragraph">
<p>We love Git. We use it, and by now so do most of you. Used conservatively, Git provides a good basis for information management (it keeps everything!).</p>
</div>
<div class="paragraph">
<p>But it is important to understand Git&#8217;s limits. Without a live connection to the editors, merge tools etc that munge the files, Git is relegated to simply discovering what has changed in the filesystem, and wisely just stores new stuff, using content-based addressing to determine what is new.</p>
</div>
<div class="paragraph">
<p>Any further information we get from such a recording of novelty has to be derived. Diffs derive mechanical change information, and tree and file diffs are at the core of Git&#8217;s facilities.</p>
</div>
<div class="paragraph">
<p>Language-aware analyses can derive change information co-aligned with program semantics.</p>
</div>
<div class="sect3">
<h4 id="_how_it_works">How it works</h4>
<div class="paragraph">
<p>Git looks in directories and finds files, names them by the SHAs of their contents, and encodes their relationship to the enclosing tree by filename. During the import phase, <strong>codeq</strong> pretty much transfers Git&#8217;s model intact.</p>
</div>
<div class="paragraph">
<p>During the analysis phase, <strong>codeq</strong> looks in files and finds code segments, names them by their SHAs, and encodes their relationship to the enclosing file by line+column location. It further associates them with programmatic names and semantics (e.g. definition, or usage), if possible. We call this semantic segment a <strong><em>codeq</em></strong>.</p>
</div>
<div class="paragraph">
<p>Thus, one way to understand <strong>codeq</strong> is as an extension of the git model and tree down to a finer granularity, aligned to program semantics.</p>
</div>
<div class="paragraph">
<p><strong>codeq Model</strong></p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-rVnhRVfSFQ0/UHTuU7cbX_I/AAAAAAAAAKE/wT9IftO5QHM/s1600/codeq-overview.png" alt="codeq model diagram">
</div>
</div>
<div class="paragraph">
<p>In Git, every repo is an island. When trying to understand the interactions across your entire program, including the many libraries it uses, each with their own Git repo, it becomes useful to combine repo information in a single database. The beauty of content-based addressing and globally unique namespacing (as done by e.g. Java and Clojure) is that such merging is conflict-free. So, <strong>codeq</strong> supports the importation of multiple repos into the same database and keeps them sorted, superimposing a level above the Git model.</p>
</div>
</div>
<div class="sect3">
<h4 id="_in_detail">In Detail</h4>
<div class="paragraph">
<p>Now we can consider a particular scenario - a programmer edits a file, changing one function definition and inserting another.</p>
</div>
<div class="paragraph">
<p>From the Git perspective, the two files are different blobs, with different SHAs, in different trees under the same name. Anything else it tells you about what has changed is done via dynamic diffing, and is usually expressed in terms of lines and blocks of text.</p>
</div>
<div class="paragraph">
<p>Since we know (some of) these files are programs, and they are stored immutably, it seems worthwhile to perform a one-time analysis in order to track change more finely. <strong>codeq</strong> will break down the top level of the file into the corresponding program-language units (e.g. for Clojure, mostly function-defining forms). It gives each a SHA (if the block of code has never been seen before). It will then look inside and try to determine what the code is about (in context - since the same code can appear e.g. in different namespaces and thus name different things). The 'meaning' is normally some reference to a namespaced program identity, and for some purpose (definition, use). So a <strong><em>codeq</em></strong> encodes the location of a code segment in a file, and its semantics.</p>
</div>
<div class="paragraph">
<p><strong>File edit:</strong></p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-ISvFQKIEr68/UHTu8e8TzgI/AAAAAAAAAKM/vaiDTVelo1I/s1600/codeq-file.png" alt="codeq file edit diagram">
</div>
</div>
<div class="paragraph">
<p>After the edit, the analysis finds the identical first 2 segments in the same place in the new file, a new segment following, and then the old 3rd segment in a new location. The file ends with a new code segment, but is 'about' the same thing as the prior 4th segment. As time goes by we can get timelines for program constructs that are independent of the timelines of the files that contain them, and more closely aligned with our work (what&#8217;s the history of this function definition?)</p>
</div>
<div class="paragraph">
<p>This importation and analysis is not a one-shot thing. You continue to use Git normally. You can go back later and import your newer changes from Git, or perform new or enhanced analyses. Due to the first-class nature of Datomic transactions, the <strong>codeq</strong> database knows what has happened to it, what has been imported, what analyses have been run, what schemas have been installed etc.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_put_on_a_happy_interface">Put on a happy interface</h3>
<div class="paragraph">
<p>Git has a powerful engine - durable persistent data structures with structural sharing and some fast C code that manipulates them. Unfortunately, it is hidden behind a plethora of command line utilities each of which has a boatload of options and a variety of outputs - let&#8217;s have a parsing party!</p>
</div>
<div class="paragraph">
<p>If only we had some declarative query technology with elegant support for recursion, we could turn all this tree walking into a piece of cake. Wait! - we can fight 1970&#8217;s technology with&#8230;&#8203; more 1970&#8217;s technology - Datalog</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(def rules
 '[[(node-files ?n ?f) [?n :node/object ?f] [?f :git/type :blob]]
 [(node-files ?n ?f) [?n :node/object ?t] [?t :git/type :tree]
 [?t :tree/nodes ?n2] (node-files ?n2 ?f)]
 [(object-nodes ?o ?n) [?n :node/object ?o]]
 [(object-nodes ?o ?n) [?n2 :node/object ?o] [?t :tree/nodes ?n2] (object-nodes ?t ?n)]
 [(commit-files ?c ?f) [?c :commit/tree ?root] (node-files ?root ?f)]
 [(commit-codeqs ?c ?cq) (commit-files ?c ?f) [?cq :codeq/file ?f]]
 [(file-commits ?f ?c) (object-nodes ?f ?n) [?c :commit/tree ?n]]
 [(codeq-commits ?cq ?c) [?cq :codeq/file ?f] (file-commits ?f ?c)]])</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can follow along with <a href="https://github.com/downloads/Datomic/codeq/codeq.pdf">the schema</a>, but suffice to say, that is all the code you need to:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Find all the files referenced by a commit</p>
</li>
<li>
<p>Find all the codeqs referenced by a commit</p>
</li>
<li>
<p>Find all the commits including a file</p>
</li>
<li>
<p>Find all the commits including a codeq</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>This query uses those rules to find all of the different definitions of the function <code>datomic.codeq.core/commit</code>, and when they were first defined:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">(d/q '[:find ?src (min ?date)
 :in $ % ?name
 :where
 [?n :code/name ?name]
 [?cq :clj/def ?n]
 [?cq :codeq/code ?cs]
 [?cs :code/text ?src]
 [?cq :codeq/file ?f]
 (file-commits ?f ?c)
 (?c :commit/authoredAt ?date)]
 db rules "datomic.codeq.core/commit")</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you don&#8217;t know Datalog, it&#8217;s worth the <a href="https://www.datomic.com/videos.html#query">11 minutes</a> it will take you to learn it.</p>
</div>
<hr>
<div class="paragraph">
<p>I hope this gives you a sense of the motivation for <a href="https://github.com/Datomic/codeq#codeq"><strong>codeq</strong></a>, and some excitement for trying it out. It&#8217;s still early days, and we are definitely looking for help in enhancing the analysis, integrating with tools, supporting other languages etc.</p>
</div>
<div class="paragraph">
<p>Have fun!</p>
</div>
<div class="paragraph">
<p>Rich</p>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Monitoring and Performance</title>
      <link>https://blog.datomic.com/2012/09/datomic-monitoring-and-performance.html</link>
      <pubDate>Mon, 17 Sep 2012 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2012/09/datomic-monitoring-and-performance.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>I have just added a new section to the Datomic documentation on <a href="https://docs.datomic.com/operation/monitoring.html">monitoring and performance</a>. If you are tuning Datomic, it is a must-read.</p>
</div>

<div class="paragraph">
<p>I want to call attention in this blog post to one aspect of Datomic monitoring that might not be immediately apparent. Which is that you can use <a href="https://aws.amazon.com/cloudwatch/">Amazon CloudWatch</a> to monitor <em>any instance</em> of Datomic Pro, regardless of which storage you are using, and regardless of whether you are running any of your processes in the AWS cloud.</p>
</div>
<div class="paragraph">
<p>Part of the value of a good cloud architecture is being able to mix-and-match the pieces.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>REST API</title>
      <link>https://blog.datomic.com/2012/09/rest-api.html</link>
      <pubDate>Thu, 6 Sep 2012 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2012/09/rest-api.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>I&#8217;m pleased to announce that, starting with version 0.8.3488, <a href="https://www.datomic.com/">Datomic</a> now offers a REST API.</p>
</div>

<div class="paragraph">
<p>There are a number of reasons to do this, first and foremost is that it will now be possible to access Datomic from non-JVM languages.</p>
</div>
<div class="paragraph">
<p>How does it work?</p>
</div>
<div class="paragraph">
<p>The command <strong>bin/rest</strong> will start up a peer which runs as a stand-alone HTTP server. You can access that service from any application using any language and any HTTP library. That&#8217;s it!</p>
</div>
<div class="paragraph">
<p>This greatly enhances your architectural options:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="MISSING" alt="Datomic REST architecture diagram">
</div>
</div>
<div class="sect1">
<h2 id="_qa">Q&amp;A</h2>
<div class="sectionbody">
<div class="paragraph">
<p><strong>So, does this make Datomic client-server?</strong></p>
</div>
<div class="paragraph">
<p>Yes and no. First off, the 'servers' are themselves peers, so you still get elastic, configuration-free horizontal query scalability by simply starting/stopping more peers. Second, the Datomic model, which substantially mitigates the problems of client-server databases, is faithfully replicated for clients:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A peer service can serve more than one database, against more than one storage (Pro)</p>
</li>
<li>
<p>Clients get the same kind of data-driven API as do peers</p>
</li>
<li>
<p>Clients can get repeatable queries, and multiple queries with the same basis</p>
</li>
<li>
<p>Clients get the time-travel <em>as-of</em> and <em>since</em> capabilities, raw access to indexes and ranges</p>
</li>
<li>
<p>Clients can issue multi-datasource queries, and pass data to query</p>
</li>
<li>
<p>Clients can get a push feed of transaction events, via a Server-Sent Events source</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Basically, it&#8217;s just more options. Build full peers in a JVM language or lightweight clients in any language, or any combination.</p>
</div>
<div class="paragraph">
<p><strong>Do these clients count towards my peer count?</strong></p>
</div>
<div class="paragraph">
<p>No. The clients do not run the Datomic peer library, and thus do not count. Each REST service process counts as a peer.</p>
</div>
<div class="paragraph">
<p><strong>Does this work with Datomic Free?</strong></p>
</div>
<div class="paragraph">
<p>Yes it does.</p>
</div>
<div class="paragraph">
<p><strong>What&#8217;s the status of the API?</strong></p>
</div>
<div class="paragraph">
<p>It&#8217;s still alpha, as we want to incorporate your feedback.</p>
</div>
<div class="paragraph">
<p><strong>Are there client libraries for language <em><em></em>_</em>?</strong></p>
</div>
<div class="paragraph">
<p>Not yet. This is something we hope each language community will help us build.</p>
</div>
<div class="paragraph">
<p><strong>Where can I get more details?</strong></p>
</div>
<div class="paragraph">
<p>Check out the <a href="https://docs.datomic.com/reference/rest.html">REST API docs</a></p>
</div>
<div class="paragraph">
<p>We hope you enjoy this new API and the capabilities it affords. As always, we welcome your feedback and input. If you&#8217;ve been on the sidelines waiting for Datomic to come to your favorite language - welcome!</p>
</div>
</div>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>ElastiCache in 5 minutes</title>
      <link>https://blog.datomic.com/2012/09/elasticache-in-5-minutes.html</link>
      <pubDate>Mon, 3 Sep 2012 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2012/09/elasticache-in-5-minutes.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>You can add ElastiCache to your AWS-based Datomic system in minutes:</p>
</div>

<div class="ulist">
<ul>
<li>
<p>Login to your <a href="https://console.aws.amazon.com/elasticache/home">ElastiCache management console</a> and choose "Launch Cache Cluster"</p>
</li>
<li>
<p>Complete the wizard. You can accept all defaults.</p>
</li>
<li>
<p>Back at the console, select "Cache Security Groups":</p>
</li>
</ul>
</div>
<div class="imageblock">
<div class="content">
<img src="MISSING" alt="ElastiCache Cache Security Groups console screenshot">
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>&#8230;&#8203; and authorize your Datomic system&#8217;s security group (default is "datomic"):</p>
</li>
</ul>
</div>
<div class="imageblock">
<div class="content">
<img src="MISSING" alt="Authorized security group screenshot">
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Back at the console, select "Cache Clusters" and copy the node endpoints string:</p>
</li>
</ul>
</div>
<div class="imageblock">
<div class="content">
<img src="MISSING" alt="Node endpoints string screenshot">
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Paste the node endpoints into your <a href="https://docs.datomic.com/operation/storage.html">transactor properties</a> file:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre>    memcached=foo.use1.cache.amazonaws.com:11211</pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Set the node endpoints in your peer application code:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre>    System.setProperty
    ("datomic.memcachedServers",
     "foo.use1.cache.amazonaws.com:11211");</pre>
</div>
</div>
<div class="paragraph">
<p>That&#8217;s all there is to it. Datomic will <a href="https://blog.datomic.com/2012/07/memcache.html">transparently</a> use ElastiCache. There is no need to configure any cache timeouts, or change any code. Datomic&#8217;s key names will not conflict with any other use, so you can use the cache for other tasks as well.</p>
</div>
<div class="paragraph">
<p>You can also configure different caches for different processes in the system. For example, I keep a local memcached process running at the office, so from a cold peer (my development laptop) queries are fast, even when I am connecting to a transactor that is running in the AWS cloud.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Keep Chocolate Love Atomic</title>
      <link>https://blog.datomic.com/2012/08/atomic-chocolate.html</link>
      <pubDate>Fri, 10 Aug 2012 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2012/08/atomic-chocolate.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Datomic is a database of atomic facts, or datoms, that consist of entity, attribute, value, and transaction. For example, "I love chocolate (as of tx 1000)."</p>
</div>

<div class="paragraph">
<p>Of course, I am capable of loving many things, so the <code>:loves</code> attribute should be <code>:cardinality/many</code>. Here is an abbreviated history of my loves:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">; some point in time...
[[:db/add stu :loves :chocolate]
 [:db/add stu :loves :vanilla]]

; later...
[[:db/add stu :loves :octomore]
 [:db/retract stu :loves :vanilla]]</code></pre>
</div>
</div>
<div class="paragraph">
<p>The set of all things I currently love is <em>derived</em> information, and it can be calculated from the history of atomic facts. Based on the transactions above, I currently love <code>:chocolate</code> and <code>:octomore</code>.</p>
</div>
<div class="paragraph">
<p>Datomic automatically handles this derivation, as can be seen through the <a href="https://docs.datomic.com/javadoc/index.html">entity</a> interface:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-clojure hljs" data-lang="clojure">stu.get(:loves)
=&gt; #{:chocolate :octomore}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now, imagine creating a web interface with checkboxes for different things a person might love. You initially populate the interface with my current loves, pulled from the database. I interact with the system, and you get back a set of checkbox states.</p>
</div>
<div class="paragraph">
<p>At this point, you should submit adds and retracts <em>only</em> for the new facts I created&#8201;&#8212;&#8201;not a set with an add or retract for every UI element. This is a subtle point. If I liked chocolate before, and I didn&#8217;t uncheck chocolate, what is the harm in saying "Stu likes chocolate" again?</p>
</div>
<div class="paragraph">
<p>The biggest problem is that you are lying to the database. I <em>didn&#8217;t</em> repeat my love of chocolate. What if the system also had a user interface more subtle than checkboxes, that allowed me to reiterate past preferences? You wouldn&#8217;t be able to tell the difference.</p>
</div>
<div class="paragraph">
<p>An obvious warning sign is when you find yourself submitting derived information (the set of my likes) when you actually have the facts (what I just said) in hand. Ignoring facts and recording derived information is always perilous&#8201;&#8212;&#8201;imagine managing a system that records birthdays and ages, but not birthdates.</p>
</div>
<div class="paragraph">
<p>A more subtle mistake is to abuse transactions to extract facts from derived information. You have a new derived set in hand, and the database knows how to calculate the previous derived set. Given those two things, you could write a <a href="https://docs.datomic.com/transactions/transaction-functions.html">transaction function</a> that takes the two sets and backtracks to figure out what changed.</p>
</div>
<div class="paragraph">
<p>This approach has a variant of the dishonesty problem mentioned before, in that it provides no way for me to reiterate my love for chocolate. But the other problem with this approach may be even worse: It imposes coordination in the <em>implementation</em>, where no coordination was required by the <em>domain</em>.</p>
</div>
<div class="paragraph">
<p>Let&#8217;s say that I choose, at some point in time, to start liking <code>:cheesecake</code> and <code>:nachos</code>. These are atomic choices, requiring no coordination with any historical record. If you send Datomic a set of all checkbox states, and ask it to discover <code>:cheesecake</code> and <code>:nachos</code> inside a transaction, you are manufacturing a coordination job that has no basis in reality. Unnecessary coordination is an enemy of scalability and reuse.</p>
</div>
<div class="paragraph">
<p>The root cause of confusion here is update-in-place thinking. The checkbox model exposes derived information (the current states) but not the facts (the choices the user made). Given the set of checkbox states, you should do the diff in the web tier as soon as you pull data out of the form. This still has the problem that there is no way to restate that you love chocolate, but now the scope of the problem is localized to its cause&#8201;&#8212;&#8201;the checkbox model. You can fix the problem, or not (you often don&#8217;t care, which is why checkboxes work the way they do). But at least you are not propagating the problem into the permanent record.</p>
</div>
<div class="paragraph">
<p>Datomic is built on an <a href="https://docs.datomic.com/datomic-overview.html#information-model">understanding</a> that data is created by atomic addition, not by corruptive modification. When your input source has an update-in-place model (such as checkbox states), you should convert to atomic facts before creating a transaction.</p>
</div>
<div class="paragraph">
<p>Now go eat some <a href="http://www.domori.com/">chocolate</a>.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Memcache Support</title>
      <link>https://blog.datomic.com/2012/07/memcache.html</link>
      <pubDate>Tue, 24 Jul 2012 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2012/07/memcache.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>We&#8217;re happy to announce today transparent integrated support for memcached in Datomic Pro Edition.</p>
</div>

<div class="paragraph">
<p>One of the nice things about the Datomic architecture is that the index segments kept in storage are immutable. That enables them to be cached extensively. Currently that caching happens inside the peers, which keep segments they have needed thus far in the application process heap.</p>
</div>
<div class="paragraph">
<p>While this is great for process-local working sets, there is only so much a single machine can cache. So, we&#8217;ve added support for an optional second tier of distributed, shared cache, leveraging a memcached cluster. This tier of cache can be as large as you wish, and is shared between all the peers.</p>
</div>
<div class="paragraph">
<p>The entire use of memcached is automatic and integrated - just provide the endpoints of your memcached cluster in configuration. The peer protocols will automatically both look in it, and populate it on cache misses. Being based upon immutability, there are no cache coherence problems nor expiration policy woes.</p>
</div>
<div class="paragraph">
<p>The architecture incorporating memcached looks like this:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/images/blog/-bQXEj6HWB2Q/V8caoGETT9I/AAAAAAAAAKY/WfXRpkyTPTouDTSaA8XzIgVhyvaRCnJ3ACLcB/s640/DArch.jpg" alt="Datomic architecture with memcached">
</div>
</div>
<div class="paragraph">
<p>The benefits of this are many:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>You can get a shared cache of arbitrary size - many deployments will be able to fit their entire database in memcached if desired.</p>
</li>
<li>
<p>If you are using a storage that is not otherwise distributed (e.g. unclustered PostgreSQL), the memcached tier can both almost entirely remove the read load on the single server and distribute it.</p>
</li>
<li>
<p>Even when using a distributed storage like DynamoDB, the memcached tier can reduce your read provisioning and increase speed.</p>
</li>
<li>
<p>Developers can set up a small memcached daemon locally so their DB will always feel 'hot' across process restarts.</p>
</li>
<li>
<p>The memcached tier will enable hybrid strategies where the peers, transactors and memcached are all local but the storage is remote (e.g. DynamoDB).</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Datomic is a good citizen in its use of memcached - it doesn&#8217;t need to 'own' the cluster, and all of the Datomic keys incorporate UUIDs so they won&#8217;t conflict with other application-level use of the same memcached cluster.</p>
</div>
<div class="paragraph">
<p>We hope you enjoy this feature, which is included in the Pro Edition at no extra charge.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Editions and Pricing</title>
      <link>https://blog.datomic.com/2012/07/editions-and-pricing.html</link>
      <pubDate>Tue, 24 Jul 2012 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2012/07/editions-and-pricing.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic is Free</a>. The pricing and licensing information in this blog post is outdated.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Over the past few months we&#8217;ve gotten feedback and input regarding our pricing and licensing, and we&#8217;ve revamped them to make things simpler and clearer. The subscription pricing made people feel as if the offering was a service (it&#8217;s not), as well as brought about misgivings about termination etc, so we&#8217;ve dropped it.</p>
</div>

<div class="paragraph">
<p>Here&#8217;s the new offering:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>We&#8217;ve added <a href="https://blog.datomic.com/2012/07/datomic-free-edition.html">Datomic Free Edition</a> - it&#8217;s free and redistributable</p>
</li>
<li>
<p>Datomic Pro is licensed software.</p>
</li>
<li>
<p>It is offered with a perpetual license.</p>
</li>
<li>
<p>Maintenance (updates and support) for the first 12 months is included.</p>
</li>
<li>
<p>Maintenance in subsequent years is ~50% of the license fee.</p>
</li>
<li>
<p>Pricing is yearly, and up front on web site.</p>
</li>
<li>
<p>Pricing is based upon the number of processes (transactors + peers) using the software in production in your organization.</p>
</li>
<li>
<p>Development and testing usage doesn&#8217;t count against your license limits</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>We&#8217;ve priced it such that the expenditure for maintenance roughly correlates to our older subscription pricing.</p>
</div>
<div class="paragraph">
<p>Evaluation has changed a bit as well. In all modes, Datomic Pro will require a license key. You can get a free 30-day eval key via the web site. There is no longer a 'runs for a week without a key' mode.</p>
</div>
<div class="paragraph">
<p>Note that Datomic is not just for cloud deployments - our SQL and other storage support lets you run it on-premise or in the cloud.</p>
</div>
<div class="paragraph">
<p>You can get more information on the <a href="https://www.datomic.com/get-datomic.html">editions and pricing</a> here.</p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Datomic Free Edition</title>
      <link>https://blog.datomic.com/2012/07/datomic-free-edition.html</link>
      <pubDate>Tue, 24 Jul 2012 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2012/07/datomic-free-edition.html</guid>
      	<description>
        <![CDATA[
	<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p><a href="https://www.datomic.com/contact.html#_datomic_is_free">Datomic is Free</a>. The pricing and licensing information in this blog post is outdated.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>We&#8217;re happy to announce today the release of Datomic Free Edition. This edition is oriented around making <a href="https://www.datomic.com/">Datomic</a> easier to get, and use, for open source and smaller production deployments.</p>
</div>

<div class="ulist">
<ul>
<li>
<p>Datomic Free Edition is &#8230;&#8203; free!</p>
</li>
<li>
<p>The system supports transactor-local storage</p>
</li>
<li>
<p>The peer library includes a memory database and Datomic Datalog</p>
</li>
<li>
<p>The Free transactor and peers are freely redistributable</p>
</li>
<li>
<p>The transactor supports 2 simultaneous peers</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Of particular note here is that Datomic Free Edition comes with a redistributable license, and does not require a personal/business-specific license from us. That means you can download Datomic Free, build e.g. an open source application with it, and ship/include Datomic Free binaries with your software. You can also put the Datomic Free bits into public repositories and package managers (as long as you retain the licenses and copyright notices).</p>
</div>
<div class="paragraph">
<p>There is a ton of capability included in the Free Edition, including the Datomic in-process memory database (great for testing), and the Datomic datalog engine, which works on both Datomic databases and in-memory collections. That&#8217;s right, free datalog for everyone.</p>
</div>
<div class="paragraph">
<p>You can use Datomic Free Edition in production, and you can use it in commercial applications.</p>
</div>
<div class="paragraph">
<p>Datomic Free edition is completely API-compatible with what we are now calling Datomic Pro edition (the one that pays the bills). Datomic Pro adds the ability to use additional storages like SQL and DynamoDB, support for more peers, as well as high-availability mode for transactors and our new memcache support.</p>
</div>
<div class="paragraph">
<p>You can read about the <a href="https://www.datomic.com/get-datomic.html">editions</a> here.</p>
</div>
<div class="paragraph">
<p><a href="https://www.datomic.com/get-datomic.html">Get Datomic!</a></p>
</div>
  ]]>
	</description>
    </item>
    <item>
      <title>Welcome</title>
      <link>https://blog.datomic.com/2012/07/welcome.html</link>
      <pubDate>Tue, 17 Jul 2012 00:00:00 +0200</pubDate>
      <guid isPermaLink="false">2012/07/welcome.html</guid>
      	<description>
        <![CDATA[
	<div class="paragraph">
<p>Welcome to the Datomic blog!</p>
</div>
  ]]>
	</description>
    </item>

  </channel> 
</rss>
