CS 2316 – Recitation Assignment SQL Practice Instructions:

advertisement
CS 2316 – Recitation Assignment
SQL Practice
Instructions:
In this assignment, you will NOT write any python code. (Unless you want to...but don't
turn it in!) Instead, you will turn in SQL statements in a text file (use Notepad, or some
other text editing program). Be sure to place your name, email address, and
collaboration statement at the top of your text file. Each of the problems below will be
solved with a single SQL statement (Although the statements may extend to multiple
lines as the problems get harder.) You will be provided with a description of the data in
tables, as well as a question to answer about that data. Your answer to each question will
be the SQL statement that finds or calculates the answer to the question or task. Number
your answers to match the question numbers in this document.
Note that you are not submitting factual answers to the questions in this homework.
Instead, you are submitting SQL statements that cause the DB engine to GENERATE the
answers to the questions asked in this homework.
To receive credit, your SQL statement must execute properly on the class database
(Which runs MySQL). Note that we encourage you to test your statements before
submission by running them interactively on the myPHPAdmin web interface to the class
DB located at:
http://academic-mysql.cc.gatech.edu
The people Table:
CREATE TABLE people
(id INTEGER PRIMARY KEY AUTO_INCREMENT UNIQUE NOT NULL,
name TEXT NOT NULL,
email TEXT,
age INTEGER)
Example:
id
name
email
age
1
"Jay Summet"
"summetj@gatech.edu"
70
2
"Sally Smith"
"ssmith@gatech.edu"
45
Problems:
1. (3 points) Add a new person, with your name and any email address you choose (do
NOT specify an age) into the table (Allow the DB to generate the ID!).
2. (3 points) Return (only) the name and email address from the people table where the
age is exactly 70.
3. (3 points) Return (only) the name and email address from the people table where the
email address ends with "gatech.edu".
4. (3 points) Return all columns of all records where the email field contains "007" in
any location.
5. (3 points) Change the email of any record with a name of "Jay Summet" to "summetj"
(without a @gatech.edu at the end).
6. (3 points) Remove all records from the people table where the email address ends with
"uga.edu"
Download