From brand guide: https://flsouthern.mediavalet.com/portals/fsc-brand-guidelines
CSC 3340: Databases
(Fall 2024)

Syllabus

LMS

Teachers


Assignments


Other Pages

Project 5:
MongoDB the Magnificent


Assigned: Fri Nov 08 2024
Due: 11:59:00 PM on Fri Nov 15 2024
Team Size: 2
Language: Python 3 and MongoDB (using PyMongo)
Out of: 100 points


In this project, you'll create a database in MongoDB using PyMongo and add a collection with documents. Then you'll create some Python functions to manipulate the data in the database. While working on your code, you can run a subset of my tests by downloading this tester script to the same folder as your code and running it. Since it doesn't run all the tests that I will run, it's not a guarantee of the grade I'll give you. Nevertheless, it might help find some mistakes. Test early and often!

Part 0, 10 points: Lakeland is known as Swan City, partly because of the prevalence of swans in the major lakes downtown. These swans are all descendants of a British swan donated to the city from Queen Elizabeth II! Let's pay some symbolic tribute and track some of the queen's history and ancestry. Create a new MongoDB database in PyMongo with your teamname. For example, mine is named 'kburke', so that would look like this for me:

client = pymongo.MongoClient()
database = client['kburke']
Then create a collection named 'british-royals'.

Part 1, 10 points: Add a document for Queen Elizabeth II. I looked up some information on Wikipedia that I thought was relevant. You need to have at least six fields, but the necessary ones are:

  • _id, if you don't assign one, then MongoDB will make one for you.
  • full name: The person's full name, but without any titles, etc. I will be looking for the queen's full name, Elizabeth Alexandra Mary
  • parents: a list of the _ids of parents. These can begin as empty.
  • royal name: in this case, that should be: 'Queen Elizabeth II'

Part 2, 20 points: Add documents for four more royals, who have these as their royal names:

  • King George V
  • Queen Consort Mary of Teck
  • King George VI
  • Queen Consort Elizabeth Bowes-Lyon
Include all the same fields and add any cross-wise IDs for parents as appropriate. (Your database shouldn't have any _id values where the respective document doesn't exist.) Be very careful with the full names, as that's what I'm going to be looking for.

Part 3, 20 points: Write a python function, get_id_by_full_name(collection, full_name), which returns the '_id' field of a document with the given full_name.

Part 4, 10 points: Write a python function, is_parent(collection, parent_name, child_name), which returns True if parent_name is the full name of a document that is the parent of the document with child_name as its full name.

Part 5, 10 points: Write a python function, get_parent_names(collection, full_name), which returns a list of the full names of the parents of the royal with the given full_name.

Part 6, 20 points: Write a python function, get_child_and_grandchild_names(collection, full_name), which returns a list of the full names of the children and grandchildren of the royal with the given full_name. If you haven't already, I highly recommend you add a children field to the document, similar to the parents field.

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 _project5.py all in snake_case. (For example, my file name would be: kburke_project5.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.