Assignment 5 SQL queries on a single table solved




You will be using the Babyname database on our Unix system. Use the show databases command to
make sure of the correct spelling of the database name! Test your sql statements, then put them in a file
and run the source command, directing the output (using \T) to an output file. Make sure you comment
(#) each sql statement (you can use the question as the comment) and include your name, zid and
section in both files. This is a very large database, please run your queries initially to show no more
than 50 rows from any query.
1. Show all of the tables in the database.
2. Show all of the columns and other information about all of tables in the databases.
3. Show all of the years (once only) where your first name appears. If your name doesn’t appear, use
Laura if you are female and Luke if you are male.
4. Show all of the names from your birth year. (again show each name only once).
5. What is the most popular male and female names from your birth year?
6. Show all the information about names similar to your name (or the one you used above) in
alphabetic order of the name, and within that of the count, and then of the year.
7.How many rows are in the table?
8. How many names are there in the year 1960?
9. How many names are there for each sex from the year of your father’s birth? If you don’t know what
year your father was born, use 1927.
10. List how many different names there are for each place.