IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will...
-
Upload
emerald-lucas -
Category
Documents
-
view
213 -
download
0
Transcript of IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will...
![Page 1: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/1.jpg)
IS 324/325
Notes for
Wednesday
October 30, 2013
![Page 2: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/2.jpg)
2
Class Notes
Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend
Homework: graded on Friday or over the weekend… grades will be e-mailed to you
Reading assignment for Nov 4 has been changed
No class on Wednesday, Nov 6
![Page 3: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/3.jpg)
3
Let’s Get Our “SQL Feet” Wet
Let’s play in the sandbox:
http://edu.konagora.com/SQLsandbox.php#
![Page 4: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/4.jpg)
4
Homework 1 Question 1
List the names and ages (in years) of all the actors who have not died.
SELECT first_name, surname, 2013 - born as ageFROM peopleWHERE died IS NULL ;
![Page 5: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/5.jpg)
5
Homework 1 Question 2
List the names and the release year of all the movies that were released in 1956.
SELECT title, year_released FROM moviesWHERE year_released = 1956 ;
![Page 6: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/6.jpg)
6
Homework 1 Question 3
List the names and the country code of all the French movies (the 2-letter identified for France is fr).
SELECT title, countryFROM moviesWHERE country = "fr" ;
![Page 7: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/7.jpg)
7
Homework 1 Question 4
List the names, the release year, and the country code for all the American or British movies released between 1940 and 1949 (the 2-letter identified for the United States is us and Great Britain is gb).
SELECT title, year_released , countryFROM moviesWHERE year_released BETWEEN 1940 AND 1949 AND (country = "us" OR country = "gb" );
![Page 8: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/8.jpg)
8
Homework 1 Question 5
List the names of all the movies that begin with the capital letter T.
SELECT titleFROM moviesWHERE title LIKE "T%" ;
![Page 9: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/9.jpg)
9
Practice Query (1a)
Can you replace the "OR" clause below?
SELECT title, year_released , countryFROM moviesWHERE year_released BETWEEN 1940 AND 1949 AND (country = "us" OR country = "gb" );
![Page 10: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/10.jpg)
10
Practice Query (1b)
Can you replace the "OR" claue below?
SELECT title, year_released , countryFROM moviesWHERE year_released BETWEEN 1940 AND 1949 AND country IN ("us" , "gb" ) ;
![Page 11: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/11.jpg)
11
Practice Query (2a)
List all the movies that do not begin with a capital T
![Page 12: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/12.jpg)
12
Practice Query (2b)
List all the movies that do not begin with a capital T
SELECT titleFROM moviesWHERE title NOT LIKE "T%" ;
![Page 13: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/13.jpg)
13
Practice Query (3a)
List all the movie titles and their release years in this format:
XXXXXXXXX was released in YYYY.
![Page 14: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/14.jpg)
14
Practice Query (3b)
List all the movie titles and their release years in this format:
XXXXXXXXX was released in YYYY.
SELECT title || " was released in " || year_released || "."FROM movies ;
![Page 15: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/15.jpg)
15
Practice Query (3c)
List all the movie titles and their release years in this format:
XXXXXXXXX was released in YYYY.
SELECT title || " was released in " || year_released || "." AS Output_Sentence_DemoFROM movies ;
![Page 16: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/16.jpg)
16
Practice Query (4a)
List all the movie titles and their county in this format for French and British movies:
XXXXXXXXX is a French movie.YYYYYYYYY is a British movie.
![Page 17: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/17.jpg)
17
Practice Query (4b)
List all the movie titles and their county in this format for French and British movies:
XXXXXXXXX is a French movie.YYYYYYYYY is a British movie.
SELECT title || " is a " || CASE country WHEN "fr" THEN "French" WHEN "gb" THEN "British" END || " movie."FROM movies ;
![Page 18: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/18.jpg)
18
Practice Query (4c)
SELECT title || " is a " || CASE country WHEN "fr" THEN "French" WHEN "gb" THEN "British" ELSE "country of unknown origin " END || "movie."FROM movies ;
![Page 19: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/19.jpg)
19
Practice Query (5a)
How do we remove the duplicates?
SELECT countryFROM movies ;
![Page 20: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/20.jpg)
20
Practice Query (5b)
How do we remove the duplicates?
SELECT DISTINCT countryFROM movies ;
![Page 21: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/21.jpg)
21
Practice Query (6a)
How do we capitalize the first letter of every word in the title?
SELECT titleFROM movies ;
![Page 22: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/22.jpg)
22
Practice Query (6b)
How do we capitalize the first letter of every word in the title?
SELECT initcap (title)FROM movies ;
![Page 23: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/23.jpg)
23
Practice Query (7a)
Who died most recently?
![Page 24: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/24.jpg)
24
Practice Query (7b)
Who died most recently?
SELECT first_name || " " || surname, diedFROM people WHERE died = ( SELECT max(died) FROM people) ;
![Page 25: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/25.jpg)
25
Practice Query (8a)
How many movies are there?
![Page 26: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/26.jpg)
26
Practice Query (8b)
How many movies are there?
SELECT COUNT (*)FROM movies ;
![Page 27: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/27.jpg)
27
Practice Query (9a)
How many movies are there by country?
SELECT COUNT (*)FROM movies ;
![Page 28: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/28.jpg)
28
Practice Query (9b)
How many movies are there by country?
SELECT COUNT (*), countryFROM moviesGROUP BY country ORDER BY 1 ;
![Page 29: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/29.jpg)
29
Practice Query (9c)
How many movies are there by country? Can I put them in order by "number of movies"?
SELECT COUNT (*), countryFROM moviesGROUP BY 1 ;
SELECT COUNT (*) AS Num_Movies, countryFROM moviesGROUP BY Num_Movies ;
![Page 30: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/30.jpg)
30
Practice Query (9c)
How many movies are there by country? Can I put them in order by "number of movies"?
SELECT COUNT (*), countryFROM moviesGROUP BY country ORDER BY 1 ;
SELECT COUNT (*) AS Num_Movies, countryFROM moviesGROUP BY country ORDER BY Num_Movies DESC ;
![Page 31: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/31.jpg)
31
Practice Query (10a)
What is the title of the oldest movie from each country?
![Page 32: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/32.jpg)
32
Practice Query (10b)
What is the title of the oldest movie from each country?
SELECT country, title, MIN(year_released)FROM moviesGROUP BY country ;
![Page 33: IS 324/325 Notes for Wednesday October 30, 2013. 2 Class Notes Exam #1: grading not complete… will e-mail your grade to you on Friday or over the weekend.](https://reader030.fdocuments.us/reader030/viewer/2022032804/56649e585503460f94b509aa/html5/thumbnails/33.jpg)
33
Big Data...Almost the Opposite of Relational Model
What is it and why is it important?
http://www.youtube.com/watch?v=7D1CQ_LOizA
http://www.youtube.com/watch?v=R-bypPCIE9g