Website/slides/cse4562sp2019/2019-02-08-Checkpoint1.html
2019-01-27 21:37:29 -05:00

278 lines
8.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>
<h1>Intro</h1>
<h3>CSE 4/562 Database Systems</h3>
<h5>February 01, 2019</h5>
</section>
<section>
<ul>
<li>Using CCJSQLParser</li>
<li>Using SQL ASTs</li>
<li>Select Statements</li>
<li>Create Table Statements</li>
</ul>
</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>
<dt>AllColumns</dt>
<dd>SELECT *</dd>
<dt>AllTableColumns</dt>
<dd>SELECT R.*</dd>
<dt>SelectExpressionItem</dt>
<dd>SELECT R.A or SELECT R.A AS Q</dd>
</dl>
</section>
<section>
<h2>Expressions</h2>
<ul>
<li>WHERE</li>
<li>HAVING</li>
<li>SelectExpressionItem</li>
<li>ORDER BY</li>
</ul>
(To be discussed next week)
</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>