Your name: ___________________

For each of the following questions,
give the exact, complete command that you used
to perform the given task.


1. What command could you use to see all the messages in the message table that were posted by you, but not those posted by other people?

2. What command could you use to delete all the messages that you posted? (Do it!)

3. Use an SQL command to add a message to the message table. The message should look like it was posted by you. Remember that when you use an INSERT command, you only need to supply values for some of the columns. In particular, for the message table, you only need to supply content and from_user. The other columns will be filled in automatically. Write down the exact command that you used.

4. Use an SQL command to find out how many rows there are in the user table. Write down the answer, as well as the exact command that you used to find the answer.

5. Use an SQL command to find out how many rows there are in the user table that have a "W" in the college column. Write down the answer, as well as the exact command that you used to find the answer.

6. What happens if you try to delete a row from the user table? Show the command that you used, along with the error message that it generated.

7. It's time to design a poll. You have to come up with a question and several possible answers. In class, we used the example of asking, "What is your favorite color?" You should use a different question -- hopefully something more interesting. Add your poll to the poll table. You should enter values for the creator and for the question columns. The id column will be filled in automatically. Use an identifiable name for the creator, so that I will know whose poll it is. Write down the exact command that you used.

8. Your poll has been assigned an id number. Find the id for your poll. You will need this number for the following exercise. Explain how you found it. Write down the SQL command that you used.

9. Now, add all the answers for your poll to the poll_answers table. You will need to execute one command for each answer. Write down one of the commands that you used.

10. What command can you use to check that all your answers are properly recorded in the poll_answers table?