<!DOCTYPE html>
<html lang="en-US">

  <head>
    <meta charset='utf-8'>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,maximum-scale=2">
    <link rel="stylesheet" href="assets/css/style.css?v=">
    <script src="https://code.jquery.com/jquery-3.3.0.min.js" integrity="sha256-RTQy8VOmNlT6b2PIRur37p6JEBZUE7o8wPgMvu18MC4=" crossorigin="anonymous"></script>
    <script src="assets/js/main.js"></script>
<!-- Begin Jekyll SEO tag v2.6.1 -->
<title>BIRDS | Bidirectional Transformation for Relational View Update Datalog-based Strategies</title>
<meta name="generator" content="Jekyll v4.0.0" />
<meta property="og:title" content="BIRDS" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="Bidirectional Transformation for Relational View Update Datalog-based Strategies" />
<meta property="og:description" content="Bidirectional Transformation for Relational View Update Datalog-based Strategies" />
<meta property="og:site_name" content="BIRDS" />
<script type="application/ld+json">
{"@type":"WebPage","url":"/syntax.html","headline":"BIRDS","description":"Bidirectional Transformation for Relational View Update Datalog-based Strategies","@context":"https://schema.org"}</script>
<!-- End Jekyll SEO tag -->

  </head>

  <body>

    <!-- HEADER -->
    <div id="header_wrap" class="outer">
        <header class="inner">
          
            <a id="forkme_banner" href="https://github.com/dangtv/BIRDS">View on GitHub</a>
          
          <a id="project_title" href="/BIRDS">BIRDS</a>
           <!-- <h1 id="project_title">  BIRDS </h1>  -->
          <h2 id="project_tagline">Bidirectional Transformation for Relational View Update Datalog-based Strategies</h2>

          
        </header>
    </div>

    <!-- MAIN CONTENT -->
    <div id="main_content_wrap" class="outer, wrapper">
      <div class="inner">
          <nav>
              <h3>Contents</h3>
              <ul></ul>
            </nav>
        <section id="main_content">
          <h2 id="the-datalog-core-syntax">The Datalog core Syntax</h2>
<p>In the Datalog program supported by BIRDS, a predicate <code class="highlighter-rouge">R</code> preceded by a symbol <code class="highlighter-rouge">+</code>/<code class="highlighter-rouge">-</code> (called a delta predicate) corresponds to the set of tuples that need to be inserted/deleted into/from table <code class="highlighter-rouge">R</code>.
The core syntax for Datalog supported by BIRDS is the following:</p>
<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;program&gt; ::= {&lt;statement&gt;} &lt;statement&gt;
&lt;statement&gt; ::= &lt;schema&gt; | &lt;constraint&gt; | &lt;rule&gt;
&lt;schema&gt; ::= "source:" &lt;relname&gt; "(" &lt;attribute&gt;:&lt;type&gt; {"," &lt;attribute&gt;:&lt;type&gt;} ")" "." 
 | "view:" &lt;relname&gt; "(" &lt;attribute&gt;:&lt;type&gt; {"," &lt;attribute&gt;:&lt;type&gt;} ")" "."
&lt;rule&gt; ::= &lt;predicate&gt; ":-" &lt;literal&gt; { ("and"| ",") &lt;literal&gt; } "."
&lt;constraint&gt;::= ("⊥" | "_|_") ":-" &lt;literal&gt; { ("and"| ",") &lt;literal&gt; } "."
&lt;literal&gt; ::= &lt;predicate&gt; | ("not" | "¬") &lt;predicate&gt; | &lt;builtin&gt; | "not" &lt;builtin&gt;
&lt;predicate&gt; ::= [ ("+" | "-") ] &lt;relname&gt; "(" &lt;term&gt; {"," &lt;term&gt;} ")"
&lt;builtin&gt; ::= &lt;varname&gt; ("=" | "&lt;&gt;" | "&lt;" | "&gt;" | "&lt;=" | "&gt;=") &lt;const&gt;
&lt;term&gt; ::= &lt;varname&gt; | &lt;anonvar&gt; | &lt;const&gt;
&lt;varname&gt; ::= 'A'|..|'Z' { ('A'|..|'Z'| '0'|..|'9'|'_') }
&lt;relname&gt; ::= 'a'|..|'z'|'_' { ('a'|..|'z'| '0'|..|'9'|'_') }
&lt;attribute&gt; ::= 'a'|..|'z'|'_' { ('a'|..|'z'| '0'|..|'9'|'_') }
&lt;type&gt; ::= int | float | string
&lt;anonvar&gt; ::= '_'
&lt;const&gt; ::= &lt;integer&gt; | &lt;float&gt; | &lt;string&gt;
</code></pre></div></div>

<p>In general, the verification in BIRDS is sound. BIRDS guarantees the completeness of the verification if all Datalog rules are negation guarded.</p>

<h2 id="abbreviated-syntax">Abbreviated syntax</h2>

<h3 id="primary-key">Primary key</h3>

<p>BIRDS provides a shorthand syntax to declare primary keys on relations.
Given a relation t(<strong>A</strong>, B, C), we can declare <strong>A</strong> as a primary key of t by:</p>

<div class="language-prolog highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">PK</span><span class="p">(</span><span class="ss">t</span><span class="p">,[</span><span class="nv">A</span><span class="p">]).</span>
</code></pre></div></div>
<p>That is an abbreviation for the following rules:</p>

<div class="language-prolog highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">% for the functional dependency A -&gt; B:</span>
<span class="nv">_</span><span class="p">|</span><span class="nv">_</span> <span class="p">:-</span> <span class="ss">t</span><span class="p">(</span><span class="nv">A</span><span class="p">,</span><span class="nv">B1</span><span class="p">,</span><span class="nv">_</span><span class="p">),</span> <span class="ss">t</span><span class="p">(</span><span class="nv">A</span><span class="p">,</span><span class="nv">B2</span><span class="p">,</span><span class="nv">_</span><span class="p">),</span> <span class="ss">not</span> <span class="nv">B1</span> <span class="o">=</span> <span class="nv">B2</span><span class="p">.</span>
<span class="c1">% for the functional dependency A -&gt; C:</span>
<span class="nv">_</span><span class="p">|</span><span class="nv">_</span> <span class="p">:-</span> <span class="ss">t</span><span class="p">(</span><span class="nv">A</span><span class="p">,</span><span class="nv">_</span><span class="p">,</span><span class="nv">C1</span><span class="p">),</span> <span class="ss">t</span><span class="p">(</span><span class="nv">A</span><span class="p">,</span><span class="nv">_</span><span class="p">,</span><span class="nv">C2</span><span class="p">),</span> <span class="ss">not</span> <span class="nv">C1</span> <span class="o">=</span> <span class="nv">C2</span><span class="p">.</span>
</code></pre></div></div>

<p>Consider a relation s(<strong>A</strong>, <strong>B</strong>, C, D), where two columns <strong>A</strong> and <strong>B</strong> form the primary key of s(<strong>A</strong>, <strong>B</strong>, C, D).
We declare this constraint by:</p>

<div class="language-prolog highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">PK</span><span class="p">(</span><span class="ss">t</span><span class="p">,[</span><span class="nv">A</span><span class="p">,</span><span class="nv">B</span><span class="p">]).</span>
</code></pre></div></div>
<p>That is an abbreviation for the following rules:</p>

<div class="language-prolog highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">% for the functional dependency (A,B) -&gt; C:</span>
<span class="nv">_</span><span class="p">|</span><span class="nv">_</span> <span class="p">:-</span> <span class="ss">s</span><span class="p">(</span><span class="nv">A</span><span class="p">,</span><span class="nv">B</span><span class="p">,</span><span class="nv">C1</span><span class="p">,</span><span class="nv">_</span><span class="p">),</span> <span class="ss">s</span><span class="p">(</span><span class="nv">A</span><span class="p">,</span><span class="nv">B</span><span class="p">,</span><span class="nv">C2</span><span class="p">,</span><span class="nv">_</span><span class="p">),</span> <span class="ss">not</span> <span class="nv">C1</span> <span class="o">=</span> <span class="nv">C2</span><span class="p">.</span>
<span class="c1">% for the functional dependency (A,B) -&gt; D:</span>
<span class="nv">_</span><span class="p">|</span><span class="nv">_</span> <span class="p">:-</span> <span class="ss">s</span><span class="p">(</span><span class="nv">A</span><span class="p">,</span><span class="nv">B</span><span class="p">,</span><span class="nv">_</span><span class="p">,</span><span class="nv">D1</span><span class="p">),</span> <span class="ss">s</span><span class="p">(</span><span class="nv">A</span><span class="p">,</span><span class="nv">B</span><span class="p">,</span><span class="nv">_</span><span class="p">,</span><span class="nv">D2</span><span class="p">),</span> <span class="ss">not</span> <span class="nv">D1</span> <span class="o">=</span> <span class="nv">D2</span><span class="p">.</span>
</code></pre></div></div>

        </section>
      </div>
    </div>
    
    <!-- FOOTER  -->
    <div id="footer_wrap" class="outer">
      <footer class="inner">
        <p style="margin-bottom:0em"><small>
          
          Maintained by <a href="https://dangtv.github.io">Vandang Tran</a>, Hiroyuki Kato, Zhenjiang Hu</small>.
        
        <small>Theme based on <a href="https://github.com/pages-themes/slate">Slate</a></small>.
        <small>Last updated on 2 Dec 2020</small></p>
      </footer>
    </div>

    
  </body>
</html>