462 lines
16 KiB
HTML
462 lines
16 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
|
||
<head>
|
||
<meta charset="utf-8">
|
||
|
||
<title>CSE 4/562</title>
|
||
|
||
<meta name="description" content="CSE 4/562">
|
||
<meta name="author" content="Oliver Kennedy">
|
||
|
||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
|
||
|
||
<link rel="stylesheet" href="../reveal.js-3.6.0/css/reveal.css">
|
||
<link rel="stylesheet" href="ubodin.css" id="theme">
|
||
|
||
<!-- Code syntax highlighting -->
|
||
<link rel="stylesheet" href="../reveal.js-3.6.0/lib/css/zenburn.css">
|
||
|
||
<!-- Printing and PDF exports -->
|
||
<script>
|
||
var link = document.createElement( 'link' );
|
||
link.rel = 'stylesheet';
|
||
link.type = 'text/css';
|
||
link.href = window.location.search.match( /print-pdf/gi ) ? '../reveal.js-3.6.0/css/print/pdf.css' : '../reveal.js-3.6.0/css/print/paper.css';
|
||
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
||
</script>
|
||
|
||
<!--[if lt IE 9]>
|
||
<script src="../reveal.js-3.6.0/lib/js/html5shiv.js"></script>
|
||
<![endif]-->
|
||
</head>
|
||
|
||
<body>
|
||
|
||
<div class="reveal">
|
||
<!-- Any section element inside of this container is displayed as a slide -->
|
||
|
||
<div class="header">
|
||
<!-- Any Talk-Specific Header Content Goes Here -->
|
||
CSE 4/562 - Database Systems
|
||
</div>
|
||
<div class="footer">
|
||
<!-- Any Talk-Specific Footer Content Goes Here -->
|
||
<div style="float: left; margin-top: 15px; ">
|
||
Exploring <u><b>O</b></u>nline <u><b>D</b></u>ata <u><b>In</b></u>teractions
|
||
</div>
|
||
<img src="graphics/LabLogo-FullText-white.png" height="40" style="float: right;"/>
|
||
</div>
|
||
|
||
<div class="slides">
|
||
|
||
<section>
|
||
<section>
|
||
<h2>Practicum: Checkpoint 0</h2>
|
||
<h3>CSE 4/562 – Database Systems</h3>
|
||
<h5>February 01, 2019</h5>
|
||
</section>
|
||
|
||
</section>
|
||
|
||
<section>
|
||
<svg width="600" height="500">
|
||
<g transform="translate(0 -100)">
|
||
<image x="0" y="150" xlink:href="graphics/Clipart/Java.png" width="120" height="120"
|
||
class="fragment" data-fragment-index="1" />
|
||
<text x="0" y="120" font-size="18pt"
|
||
class="fragment" data-fragment-index="1" >You write code</text>
|
||
|
||
<polygon points="120,210 240,210 220,206 220,214 240,210"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
class="fragment" data-fragment-index="2" />
|
||
<image x="240" y="150" xlink:href="graphics/Clipart/GIT.png" width="120" height="120"
|
||
class="fragment" data-fragment-index="2" />
|
||
<text x="220" y="120" font-size="18pt"
|
||
class="fragment" data-fragment-index="2" >You push to GIT</text>
|
||
|
||
<polygon points="360,210 470,210 450,206 450,214 470,210"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
class="fragment" data-fragment-index="3" />
|
||
<image x="480" y="150" xlink:href="graphics/2019-02-01-Submit.png" width="120" height="102"
|
||
class="fragment" data-fragment-index="3" />
|
||
<text x="480" y="120" font-size="18pt"
|
||
class="fragment" data-fragment-index="3" >Hit Submit</text>
|
||
|
||
<polygon points="540,262 540,345 536,325 544,325 540,345"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
class="fragment" data-fragment-index="4" />
|
||
<image x="480" y="350" xlink:href="graphics/Clipart/JAR.png" width="120" height="120"
|
||
class="fragment" data-fragment-index="4" />
|
||
<text x="400" y="520" font-size="18pt"
|
||
class="fragment" data-fragment-index="4" >DµBStep compiles</text>
|
||
|
||
<polygon points="485,410 370,410 390,406 390,414 370,410"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
class="fragment" data-fragment-index="5" />
|
||
<image x="240" y="320" xlink:href="graphics/2019-02-01-PiGrader.jpeg" width="120" height="160"
|
||
class="fragment" data-fragment-index="5" />
|
||
<text x="265" y="520" font-size="18pt"
|
||
class="fragment" data-fragment-index="5" >π s Run</text>
|
||
|
||
<polygon points="230,410 120,410 140,406 140,414 120,410"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
class="fragment" data-fragment-index="6" />
|
||
<image x="0" y="350" xlink:href="graphics/Clipart/Email.png" width="120" height="107"
|
||
class="fragment" data-fragment-index="6" />
|
||
<text x="0" y="520" font-size="18pt"
|
||
class="fragment" data-fragment-index="6" >You get emailed</text>
|
||
|
||
<polygon points="60,350 60,270 56,290 64,290 60,270"
|
||
stroke="black" stroke-width="2"
|
||
class="fragment" data-fragment-index="7" />
|
||
<text x="20" y="320" font-size="18pt"
|
||
class="fragment" data-fragment-index="7" >Try again</text>
|
||
</g>
|
||
</svg>
|
||
</section>
|
||
|
||
<section>
|
||
<h2>Query Processor</h2>
|
||
<svg width="800" height="500">
|
||
|
||
<text x="0" y="70">SQL Query</text>
|
||
|
||
<g class="fragment">
|
||
<polygon points="80,0 0,0 20,-4 20,4 0,0"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
transform="translate(287 58) rotate(180)"/>
|
||
<text x="300" y="70">Parsed SQL</text>
|
||
</g>
|
||
|
||
<g class="fragment">
|
||
<polygon points="80,0 0,0 20,-4 20,4 0,0"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
transform="translate(587 58) rotate(180)"/>
|
||
<text x="600" y="70">Rel. Alg.</text>
|
||
</g>
|
||
|
||
<g class="fragment">
|
||
<polygon points="120,0 0,0 20,-4 20,4 0,0"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
transform="translate(660 210) rotate(270)"/>
|
||
<text x="470" y="160">Statistics</text>
|
||
<polygon points="55,0 0,0 20,-4 20,4 0,0"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
transform="translate(630 210) rotate(230)"/>
|
||
<text x="502" y="250">Optimized RA</text>
|
||
</g>
|
||
|
||
<g class="fragment">
|
||
<polygon points="120,0 0,0 20,-4 20,4 0,0"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
transform="translate(660 390) rotate(270)"/>
|
||
<text x="490" y="430">Execution Plan</text>
|
||
</g>
|
||
|
||
<g class="fragment">
|
||
<polygon points="220,0 0,0 20,-4 20,4 0,0"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
transform="translate(260 418)"/>
|
||
<text x="315" y="390">Data</text>
|
||
<polygon points="60,0 0,0 20,-4 20,4 0,0"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
transform="translate(260 410) rotate(330)"/>
|
||
<text x="0" y="430">Query Results</text>
|
||
</g>
|
||
|
||
<g class="fragment">
|
||
<text x="140" y="120" fill="red" font-size="16pt">JSQLParser</text>
|
||
<polyline points="200,100 240,60" stroke="red">
|
||
</g>
|
||
|
||
<g class="fragment">
|
||
<rect x="505" y="0" fill="white" width="250" height="800" opacity="0.7"/>
|
||
<rect x="250" y="100" fill="white" width="255" height="400" opacity="0.7"/>
|
||
<polygon points="350,0 0,0 20,-4 20,4 0,0"
|
||
stroke="black" fill="black" stroke-width="2"
|
||
transform="translate(215 395) rotate(295)"/>
|
||
<text x="50" y="250" font-size="20pt">Checkpoint 0</text>
|
||
</g>
|
||
|
||
</svg>
|
||
</section>
|
||
|
||
<section>
|
||
<h2>DµBStep</h2>
|
||
<dl>
|
||
<dt>Checkpoint 0: "Hello World" due Feb 10</dt>
|
||
<dd><pre><code class="sql">SELECT * FROM FOO</code></pre></dd>
|
||
<dt>Checkpoint 1: "Expressions" due Mar 9</dt>
|
||
<dd><pre><code class="sql">SELECT A*23 FROM FOO WHERE B > 10</code></pre></dd>
|
||
<dt>Checkpoint 2: "Precomputation" due Apr 13</dt>
|
||
<dd><pre><code class="sql">SELECT SUM(A) FROM FOO WHERE B > 10</code></pre></dd>
|
||
<dt>Checkpoint 3: "Joins" due May 11</dt>
|
||
<dd><pre><code class="sql">SELECT SUM(A) FROM FOO, BAR WHERE B > 10</code></pre></dd>
|
||
</section>
|
||
|
||
</section>
|
||
|
||
<section>
|
||
<section>
|
||
<h2>Getting Started</h2>
|
||
</section>
|
||
<section>
|
||
<img src="graphics/DuBStep/Syllabus.png" height="400px"/>
|
||
<p>A link to the submission system is on the syllabus.</p>
|
||
</section>
|
||
<section>
|
||
<img src="graphics/DuBStep/Signin.png" />
|
||
<p>There's a handy "create account" link.</p>
|
||
</section>
|
||
<section>
|
||
<img src="graphics/DuBStep/CreateAccount.png" />
|
||
<p>Use your UBIT email address to create an account.</p>
|
||
</section>
|
||
<section>
|
||
<h3>TODO By <u>Feb 8</u></h3>
|
||
<ol>
|
||
<li>Create a group of up to 3 people</li>
|
||
<li>Register your group</li>
|
||
<li>Access your group's GIT repository</li>
|
||
<li>Download <a href="http://maven.mimirdb.info/info/mimirdb/jsqlparser/1.0.0/jsqlparser-1.0.0.jar">JSQLParser</a></li>
|
||
<li>Look at the <a href="http://doc.odin.cse.buffalo.edu/jsqlparser/">JSQLParser Javadoc</a></li>
|
||
<li>Read the <a href="https://odin.cse.buffalo.edu/teaching/cse-562/2017sp/checkpoint0.html">Checkpoint 0 Overview</a></li>
|
||
<li>Create a SQL "Hello World" program</li>
|
||
<li>Hit Submit</li>
|
||
</ol>
|
||
</section>
|
||
<section>
|
||
<h2>A SQL "Hello World"</h2>
|
||
<ol>
|
||
<li>Read <b style="font-family: Courier, fixed-width;">SELECT * FROM [tablename]</b> from <b style="font-family: Courier, fixed-width;"><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/System.html#in">System.in</a></b></li>
|
||
<li style="margin-top: 20px">Use <a href="http://maven.mimirdb.info/info/mimirdb/jsqlparser/1.0.0/jsqlparser-1.0.0.jar">JSQLParser</a> to parse the query
|
||
<ul>
|
||
<li style="font-size:20pt">You don't need to use JSQLParser... but it will make your life easier later.</li>
|
||
</ul></li>
|
||
<li style="margin-top: 20px">Get the <a href="http://doc.odin.cse.buffalo.edu/jsqlparser/net/sf/jsqlparser/statement/select/PlainSelect.html#getFromItem--">Table Name</a></li>
|
||
<li style="margin-top: 20px">Read in the file <b style="font-family: Courier, fixed-width;">data/[tablename].csv</b></li>
|
||
<li style="margin-top: 20px">Write the contents out to <b style="font-family: Courier, fixed-width;"><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/System.html#out">System.out</a></b></li>
|
||
</ol>
|
||
</section>
|
||
|
||
<section>
|
||
<h3>Submit as many times as you need to</h3>
|
||
|
||
<h4>Your grade will never ever decrease because you decided to submit just one more time</h4>
|
||
</section>
|
||
|
||
</section>
|
||
|
||
<section>
|
||
<section>
|
||
<h2>Using CCJSqlParser</h2>
|
||
|
||
<pre><code class="java">
|
||
// StringReaders create a reader from a string
|
||
Reader input = new StringReader("SELECT * FROM R")
|
||
|
||
// CCJSqlParser takes a Reader or InputStream
|
||
CCJSqlParser parser = new CCJSqlParser(input)
|
||
|
||
// CCJSqlParser.Statement() returns the next
|
||
// complete Statement object from the reader or
|
||
// input stream (or null if the stream is empty).
|
||
Statement statement = parser.Statement()
|
||
</code></pre>
|
||
</section>
|
||
<section>
|
||
<h2>Using CCJSqlParser</h2>
|
||
|
||
<pre><code class="java">
|
||
// System.in is an InputStream
|
||
CCJSqlParser parser = new CCJSqlParser(System.in)
|
||
|
||
Statement statement = parser.Statement();
|
||
// loop until you hit the last statement
|
||
while(statement != null){
|
||
|
||
//
|
||
// Do something with statement
|
||
//
|
||
|
||
// ... then read the next statement
|
||
statement = parser.Statement();
|
||
}
|
||
</code></pre>
|
||
</section>
|
||
</section>
|
||
|
||
<section>
|
||
<section>
|
||
<h2>Abstract Syntax Trees</h2>
|
||
|
||
<ul>
|
||
<li><b>Statement</b>: Select, CreateTable</li>
|
||
<li class="fragment" data-fragment-index="1"><b>SelectBody</b>: PlainSelect, Union</li>
|
||
<li class="fragment" data-fragment-index="1"><b>FromItem</b>: Table, Join, SubSelect</li>
|
||
<li class="fragment" data-fragment-index="1"><b>SelectItem</b>: AllColumns, AllTableColumns, SelectExpressionItem</li>
|
||
<li class="fragment" data-fragment-index="1"><b>Expression</b>: LongValue, AddExpression, GreaterThan</li>
|
||
</ul>
|
||
</section>
|
||
|
||
<section>
|
||
<pre><code class="java">
|
||
while(statement != null){
|
||
if(statement instanceof Select){
|
||
Select select = (Select)statement;
|
||
// Do something with `select`
|
||
|
||
} else if(statement instanceof CreateTable){
|
||
CreateTable create = (CreateTable)statement;
|
||
// Do something with `create`
|
||
|
||
} else {
|
||
throw new SqlException("Can't handle: "+statement);
|
||
}
|
||
statement = parser.Statement()
|
||
}
|
||
</code></pre>
|
||
</section>
|
||
|
||
<section>
|
||
<pre><code class="java">
|
||
Select select = (Select)statement;
|
||
SelectBody body = select.getSelectBody();
|
||
if(body instanceof /* ... */){
|
||
// ...
|
||
}
|
||
</code></pre>
|
||
<ul class="fragment">
|
||
<li><b>PlainSelect</b>: <tt>(SELECT * FROM ...)</tt></li>
|
||
<li><b>Union</b>: <tt>(SELECT * FROM ...) UNION ALL (SELECT ...)</tt></li>
|
||
</ul>
|
||
</section>
|
||
|
||
<section>
|
||
<pre><code class="java">
|
||
Select select = (Select)statement;
|
||
SelectBody body = select.getSelectBody();
|
||
if(body instanceof PlainSelect){
|
||
PlainSelect plain = (PlainSelect)body;
|
||
// Do something with `plain`
|
||
}
|
||
</code></pre>
|
||
</section>
|
||
</section>
|
||
|
||
<section>
|
||
<section>
|
||
<h2>PlainSelect</h2>
|
||
<pre><code class="sql">
|
||
SELECT [distinct] [selectItems]
|
||
FROM [fromItem], [joins, ...]
|
||
WHERE [where]
|
||
GROUP BY [groupByColumnReferences]
|
||
HAVING [having]
|
||
ORDER BY [orderByElements]
|
||
LIMIT [limit]
|
||
</code></pre>
|
||
Everything in [brackets] has a method in <a href="http://doc.odin.cse.buffalo.edu/jsqlparser/net/sf/jsqlparser/statement/select/PlainSelect.html">PlainSelect</a>
|
||
</section>
|
||
<section>
|
||
<h2>SelectItems</h2>
|
||
<dl>
|
||
<div class="fragment highlight-blue">
|
||
<dt>AllColumns</dt>
|
||
<dd>SELECT *</dd>
|
||
</div>
|
||
<dt>AllTableColumns</dt>
|
||
<dd>SELECT R.*</dd>
|
||
<dt>SelectExpressionItem</dt>
|
||
<dd>SELECT R.A or SELECT R.A AS Q</dd>
|
||
</dl>
|
||
</section>
|
||
|
||
<section>
|
||
<h3>Other Places With Expressions</h3>
|
||
<ul>
|
||
<li>WHERE</li>
|
||
<li>HAVING</li>
|
||
<li>SelectExpressionItem</li>
|
||
<li>ORDER BY</li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
|
||
</div></div>
|
||
|
||
<script src="../reveal.js-3.6.0/lib/js/head.min.js"></script>
|
||
<script src="../reveal.js-3.6.0/js/reveal.js"></script>
|
||
|
||
<script>
|
||
|
||
// Full list of configuration options available at:
|
||
// https://github.com/hakimel/../reveal.js#configuration
|
||
Reveal.initialize({
|
||
controls: false,
|
||
progress: true,
|
||
history: true,
|
||
center: true,
|
||
slideNumber: true,
|
||
|
||
transition: 'fade', // none/fade/slide/convex/concave/zoom
|
||
|
||
chart: {
|
||
defaults: {
|
||
global: {
|
||
title: { fontColor: "#333", fontSize: 24 },
|
||
legend: {
|
||
labels: { fontColor: "#333", fontSize: 20 },
|
||
},
|
||
responsiveness: true
|
||
},
|
||
scale: {
|
||
scaleLabel: { fontColor: "#333", fontSize: 20 },
|
||
gridLines: { color: "#333", zeroLineColor: "#333" },
|
||
ticks: { fontColor: "#333", fontSize: 16 },
|
||
}
|
||
},
|
||
line: { borderColor: [ "rgba(20,220,220,.8)" , "rgba(220,120,120,.8)", "rgba(20,120,220,.8)" ], "borderDash": [ [5,10], [0,0] ]},
|
||
bar: { backgroundColor: [
|
||
"rgba(220,220,220,0.8)",
|
||
"rgba(151,187,205,0.8)",
|
||
"rgba(205,151,187,0.8)",
|
||
"rgba(187,205,151,0.8)"
|
||
]
|
||
},
|
||
pie: { backgroundColor: [ ["rgba(0,0,0,.8)" , "rgba(220,20,20,.8)", "rgba(20,220,20,.8)", "rgba(220,220,20,.8)", "rgba(20,20,220,.8)"] ]},
|
||
radar: { borderColor: [ "rgba(20,220,220,.8)" , "rgba(220,120,120,.8)", "rgba(20,120,220,.8)" ]},
|
||
},
|
||
|
||
// Optional ../reveal.js plugins
|
||
dependencies: [
|
||
{ src: '../reveal.js-3.6.0/lib/js/classList.js', condition: function() { return !document.body.classList; } },
|
||
{ src: '../reveal.js-3.6.0/plugin/math/math.js',
|
||
condition: function() { return true; },
|
||
mathjax: '../reveal.js-3.6.0/js/MathJax.js'
|
||
},
|
||
{ src: '../reveal.js-3.6.0/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
||
{ src: '../reveal.js-3.6.0/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
||
{ src: '../reveal.js-3.6.0/plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
|
||
{ src: '../reveal.js-3.6.0/plugin/zoom-js/zoom.js', async: true },
|
||
{ src: '../reveal.js-3.6.0/plugin/notes/notes.js', async: true },
|
||
// Chart.min.js
|
||
{ src: '../reveal.js-3.6.0/plugin/chart/Chart.min.js'},
|
||
// the plugin
|
||
{ src: '../reveal.js-3.6.0/plugin/chart/csv2chart.js'},
|
||
{ src: '../reveal.js-3.6.0/plugin/svginline/es6-promise.auto.js', async: false },
|
||
{ src: '../reveal.js-3.6.0/plugin/svginline/data-src-svg.js', async: false }
|
||
]
|
||
});
|
||
|
||
</script>
|
||
|
||
</body>
|
||
</html>
|