MySQL
Exercises
Were
using
the
data
set
from
courseras
DB
class
https://class.coursera.org/db/quiz/attempt?quiz_id=128.
We
planned
to
use
this
since
you
can
use
their
site
to
run
queries
and
get
feedback
without
setting
up
MySQL
but
it
seems
that
this
is
currently
down.
Weve
used
some
of
their
exercises,
removed
some,
and
added
others.
Exercise
0
Do
the
suggested
reading
and
setup
MySQL
on
scripts.mit.edu,
if
you
havent
already:
6.470.scripts.mit.edu/2013/assets/resources/MySQL%20Reading.pdf
Download
the
database
export
so
you
can
import
it
to
do
the
exercises:
http://6.470.scripts.mit.edu/2013/assets/resources/rating.sql
Open
this
SQL
file
and
copy
all
of
the
text.
Go
to
phpMyAdmin,
select
your
test
database,
and
go
to
the
SQL
tab.
Paste
the
contents
of
rating.sql
and
click
go.
You
should
now
have
the
database
for
testing.
You
may
have
to
reload
your
page
to
see
the
tables
listed
in
the
left
column.
Now
go
back
to
the
SQL
tab
for
doing
the
exercises.
Exercise
1
Find
the
titles
of
all
movies
directed
by
Steven
Spielberg.
Exercise
2
Find
the
mID
of
all
movies
that
received
a
rating
of
4
or
5,
and
sort
them
in
increasing
order
of
ratingDate.
Exercise
3
Some
reviewers
didn't
provide
a
date
with
their
rating.
Find
the
rID
of
all
reviewers
who
have
ratings
with
a
NULL
value
for
the
date.
Exercise
4
For
the
ratings
from
exercise
4,
set
the
date
to
0000-00-00.
Exercise
5
Insert
the
following
movies
into
the
Movie
table:
mID
title
year
director
109
The
Shawshank
Redemption
1994
Frank
Darabont
110
The
Dark
Knight
2008
Christopher
Nolan
Exercise
6
Get
the
title
of
the
movie
and
rating
for
every
rating.
Exercise
7
(Hard)
Find
the
titles
of
all
movies
that
have
no
ratings.
Exercise
8
Delete
the
movies
you
added
in
exercise
5.