Exercise Tuesday

Goal: Practice using your new database commands as you build out the To do app with relationships, and become familiar with PostgreSQL documentation and adding/removing tables and columns in your database. This week is a good time to really practice using objects within other objects. Use WWW SQL Designer to help you plan out your tables and columns.


Finishing the to do list

Follow along with the example of building a to do list. Here are the requirements for the project (finish one at a time):

  • If you follow along with the video, you should have an app that: allows users to create tasks and list them out, and can have multiple lists with a getTasks method on the class Category that returns all the tasks in a particular category.
  • Build a feature to let users enter a due date when they create a new task.
  • Have the tasks sorted by their due date. Check out the MySQL documentation on ORDER BY - let the database do the sorting, not PHP.

If you made it this far, awesome! If you have time, keep going.

Animal shelter

If you finish the two projects above, make a program for an animal shelter to track the animals they currently have needing homes based on type (ex. cat/dog/bunny). Build out the following features that let a shelter worker:

  • Add types of animals to the system. A type should be something like cat, dog, bunny, etc.
  • Add a animal to the system. An animal should have a name, gender, date of admittance, and breed. When it gets added to the system, it should be added as a particular type.
  • List animals by breed or type alphabetically. (Hint: make separate pages for each of these, but write methods for these sorts)
  • List animals starting with the ones who have been in the shelter the longest.

Doctor's office

Our next program is for office administrators to track patients in a doctor's office. Ultimately you will have a doctor's office database with tables for doctor, patient, etc. Build out the following features that let an administrator:

  • Add a doctor to the system, including their name and specialty as columns.
  • Add a patient to a doctor, including their name and birthdate. Patient will be its own class, so make sure to build the relationship between a Doctor object and a Patient object.

Now the doctor's office has been grown to include many doctors with the same specialty. The doctors have organized themselves into specialty groups. So when a user wants to enter a doctor, they must first select a specialty and then add a doctor from there.

  • List all of the doctors in a particular specialty. A doctor can only have one specialty. (Hint: change the database from storing specialty as a column to giving it its own table with a relationship to a Doctor object.)
  • View a chart of doctors including the number of patients they see. Use the SQL COUNT function; practice your online search skills to figure out how it works.