<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.vistrails.org//index.php?action=history&amp;feed=atom&amp;title=Big_Data_Lab_SQL</id>
	<title>Big Data Lab SQL - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.vistrails.org//index.php?action=history&amp;feed=atom&amp;title=Big_Data_Lab_SQL"/>
	<link rel="alternate" type="text/html" href="https://www.vistrails.org//index.php?title=Big_Data_Lab_SQL&amp;action=history"/>
	<updated>2026-05-05T14:10:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.2</generator>
	<entry>
		<id>https://www.vistrails.org//index.php?title=Big_Data_Lab_SQL&amp;diff=8313&amp;oldid=prev</id>
		<title>Juliana: Created page with 'Today, we will work on SQL queries.  Before the class, please download mySQL from from http://dev.mysql.com/downloads. There are many different versions, select MySQL Community S…'</title>
		<link rel="alternate" type="text/html" href="https://www.vistrails.org//index.php?title=Big_Data_Lab_SQL&amp;diff=8313&amp;oldid=prev"/>
		<updated>2014-10-03T17:04:50Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;Today, we will work on SQL queries.  Before the class, please download mySQL from from http://dev.mysql.com/downloads. There are many different versions, select MySQL Community S…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Today, we will work on SQL queries.&lt;br /&gt;
&lt;br /&gt;
Before the class, please download mySQL from from http://dev.mysql.com/downloads.&lt;br /&gt;
There are many different versions, select MySQL Community Server.&lt;br /&gt;
&lt;br /&gt;
== Installing and starting mySQL ==&lt;br /&gt;
&lt;br /&gt;
mySQL has an extensive documentation, including installation instructions for different OSes,&lt;br /&gt;
for example, MacOS: https://dev.mysql.com/doc/refman/5.7/en/macosx-installation.html&lt;br /&gt;
and for Windows: http://www.mysql.com/why-mysql/windows/&lt;br /&gt;
&lt;br /&gt;
''Several students had trouble installing the MySQL Startup Item, do not install this option!''&lt;br /&gt;
&lt;br /&gt;
I run mySQL on MacOS, so here's what I did after I installed the system to 'start' the database:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
     shell&amp;gt; cd /usr/local/mysql&lt;br /&gt;
     shell&amp;gt; sudo ./bin/mysqld_safe&lt;br /&gt;
     (ENTER YOUR PASSWORD, IF NECESSARY)&lt;br /&gt;
     (PRESS CONTROL-Z)&lt;br /&gt;
     shell&amp;gt; bg&lt;br /&gt;
     (PRESS CONTROL-D OR ENTER &amp;quot;EXIT&amp;quot; TO EXIT THE SHELL)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also use the shortcut command: mysqlup&lt;br /&gt;
&lt;br /&gt;
To connect to the MySQL server,  on a terminal, invoke /usr/local/mysql/bin/mysql.&lt;br /&gt;
&lt;br /&gt;
You can add aliases to your shell's resource file to make it easier to access commonly used programs such as `mysql' and `mysqladmin' from the command line. I have added the following 2 lines to my .bashrc:&lt;br /&gt;
&lt;br /&gt;
     alias mysql=/usr/local/mysql/bin/mysql&lt;br /&gt;
     alias mysqladmin=/usr/local/mysql/bin/mysqladmin&lt;br /&gt;
&lt;br /&gt;
You can also modified my PATH environment variable to include /usr/local/mysql/bin:&lt;br /&gt;
&lt;br /&gt;
export PATH=$PATH:./:/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/local/hadoop-1.2.1/bin:/usr/local/pig-0.12.0/bin&lt;br /&gt;
&lt;br /&gt;
== Our running example ==&lt;br /&gt;
&lt;br /&gt;
We will work with three tables. Here are the table definitions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    create table Sailors(&lt;br /&gt;
        sid int PRIMARY KEY,&lt;br /&gt;
        sname varchar(30),&lt;br /&gt;
        rating int,&lt;br /&gt;
        age int);&lt;br /&gt;
&lt;br /&gt;
    create table Reserves(&lt;br /&gt;
        sid int,&lt;br /&gt;
        bid int,&lt;br /&gt;
        day date,&lt;br /&gt;
        PRIMARY KEY (sid, bid, day));&lt;br /&gt;
&lt;br /&gt;
    create table Boats(&lt;br /&gt;
        bid int PRIMARY KEY,&lt;br /&gt;
        bname char(20),&lt;br /&gt;
        color char(10));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can download the sample file with these statements as well as some sample data from http://vgc.poly.edu/~juliana/courses/BigData2014/Lectures/Lab-SQL/sailors-mysql.sql&lt;br /&gt;
&lt;br /&gt;
== SQL Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT	AcctNo, Amount&lt;br /&gt;
FROM	ATMWithdrawal&lt;br /&gt;
WHERE	Amount &amp;lt; 50;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
A SQL query is evaluated as follows: &lt;br /&gt;
* First the FROM clause tells us the input tables&lt;br /&gt;
* Second, the WHERE clause is evaluated for all possible combinations from the input tables&lt;br /&gt;
* Third, the SELECT clause tells us  which attributes to keep in the query answer&lt;/div&gt;</summary>
		<author><name>Juliana</name></author>
	</entry>
</feed>