Florida Southern Sunset
CSC 3340: Databases
(Fall 2024)

Syllabus

LMS

Teachers


Assignments


Other Pages

Project 0:
Water Table about the Water Table


Assigned: Wed Aug 21 2024
Due: 11:59:00 PM on Wed Sep 04 2024
Team Size: 1-3
Language: Python 3 and SQLite
Out of: 100 points


In this project, you'll create a database and a table in SQLite and use SELECT * FROM to gather information from those tables. You can test your code by running this tester script, though it doesn't run all the tests that I will run.

Part 0, 5 points: Create a new python file named <teamname>_project0.py, where <teamname> is your team's name. (You should pick a team name that no one else will pick.) Put a pydoc header with your team's info in it, e.g.:

'''Creates a database of the lakes in Lakeland, FL.
authors: Pam Borgin and Kyle Burke.'''
We're going to start by creating a table of all the named lakes in Lakeland. I found a PDF report online (map page only). In this part, you need to do some research and create a table of the lakes shown in that image. Your table, named "lakes", needs to contain records with six fields:
  • "name": The name of the lake. In the PDF above, it doesn't include the word "Lake" which you'll have to add, either before or after the given name as appropriate. If the name on the PDF above is incorrect, you may correct it. If the lake has multiple names, use the one closest to the one in the PDF above.
  • "surface_area": The (estimated) surface area of the lake, in acres. (My source didn't contain any fractions of acres.)
  • "volume": The (estimated) volume of the lake in gallons. Some lakes may not have a determined value, so you'll have to enter NULL.
  • "max_depth": The (estimated) maximum depth of the lake, in feet. Again, my source didn't have fractions (of feet) here. Some lakes may not have a determined value for this either, so you'll have to enter NULL.
  • "latitude": Latitude of the (center of the) lake. Instead of including N/S, use positive values for north of the Equator and negative for south.
  • "longitude": Longitude of the (center of the) lake. Instead of including W/E, use positive values for east of the Prime Meridian and negative for west.
When I run your code, it should create a database named "lakeland-lakes.db". Important: you might find it annoying getting the error that the table exists everytime you run your code. To fix that, I added the following code to my file, after I create the database connection, but before I create the table:
try:
    print("First... we have to delete the old table.")
    cursor.execute("DROP TABLE lakes")
except:
    pass
Remember, also, that you have to commit the changes at the end of your file in order to save them to the file:
connection.commit()
To run the tester on your code, download the .py tester file given above to the same directory where your file is, then run the tester file.

Part 1, 20 points: I found a great site that had good stats for each of the lakes. I highly recommend you check with me to see if you are using the same site. After checking that you have the correct table, I will check that you have all the names correct. Some things to keep in mind:

  • The web source I used listed all 38 lakes named in that PDF.
  • That site will show you where to put the word 'Lake' and what to capitalize.
  • If it provides multiple names for a lake, use the one closest in name to what appears on the PDF provided above. (Bonny (Little) needs to be written differently.)
I will look for each lake in the order on that original PDF. I did round volumes to the nearest thousand.

Part 2, 25 points: When you finish adding all the data, you should have 38 records in this table in the end. To get full points on this part, your stats should be relatively close to what I found.

Part 3, 5 points: Next let's write some python functions to use SELECT * FROM lakes and process the data from the table. For the first of these, write a python function, get_biggest_area_lake(db_connection), that returns the name of the lake with the largest surface area in the lakes table in the given connection. Important note: make sure your function actually goes through the table to get the answer. Before running these, I may be modifying your table and expect different answers than what are correct for real-world-Lakeland.

Part 4, 5 points: Next, write a python function, get_deepest_lake(db_connection), that returns the name of the lake with the deepest maximum depth. If a lake doesn't have a given maximum depth, ignore it.

Part 5, 5 points: Next, write a python function, get_biggest_volume_lake(db_connection), that returns the name of the lake with the biggest volume. If a lake doesn't have a given volume, ignore it.

Part 6, 10 points: Next, write a python function, get_highest_average_depth_lake(db_connection), that returns the name of the lake with the biggest average depth. "But Kyle", you might say, "we don't have a field for average depth!" Thankfully, you do have fields for surface area and volume, which you can use to find the lake with the highest average depth. Naturally, ignore those lakes which you don't have volume data for.

Part 7, 5 points: At Florida Southern, we might care about which lake is furthest south, so... write a python function, get_most_southern_lake(db_connection), that returns the name of the lake furthest to the south.

Part 8, 5 points: Some of the lakes are quite big, with over 100 million gallons of water! get_number_of_big_lakes(db_connection), that returns the number of lakes with over 100 million gallons of water.

Part 9, 10 points: We might care about lakes past a certain line of longitude or latitude. Write get_number_west(db_connection, longitude), that returns the number of lakes west of a certain line of longitude. (Oh my gosh, two parameters!!!!)

Part 10, 5 points: This one's tricky! Write get_deepest_western_lakes(db_connection), which returns a list of the names of all lakes that don't have a deeper lake to their west (in Lakeland).

Submitting your Project:

Choose a team name that no other team will choose. Then make sure all your code is in a file labelled with your team name, followed by _project0.py all in snake_case. (For example, my file name would be: kburke_project0.py.) It's very important to name your file correctly in order for me to grade it. Make sure your code runs, then upload it to the project on Canvas. If there is already a file up on Canvas, I recommend deleting that before uploading the new version. If you submit well before the deadline, send me a message on Slack. If there's adequate time, I'll check it and post feedback on Canvas. If you submit after the deadline, please message me so I know I have something late to grade.