Exercise Monday

Goal: The goal for today is to practice creating a many-to-many relationship between your tables in your database and to use that relationship to create objects that belong to other objects.


Finishing the To Do List

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

  • Follow along with the lessons and you should have an app that allows users to create tasks and list them out. And add the ability to have multiple categories with a tasks() method that returns all the tasks in a particular list.
  • Let users mark tasks as done without deleting them, so that they can view all of their completed tasks later. Hint: create a new attribute for a task that returns a boolean if true/false.
  • If you haven't already, build a feature to let users enter a due date for a task.
  • Sort tasks by their due date. Check out the MySQL documentation on ORDER BY - let the database do the sorting, not PHP.


Once you've finished the to do list, create an application that allows users to post to a blog, and organize their posts. Here are some user stories to guide your work:

  • As a user, I want to add a post with information I'd like to share with the world.
  • As a user, I want to tag my posts with different categories like "Travel", "DIY", or "Cooking", so posts are easier to find.
  • As a user, I want to associate a post with a tag. A post should be able to have many tags and a tag should be able to include many posts.
  • As a user, I want to be able to update and delete tags, so I can have flexibility with how I categorize posts.
  • As a user, I want to edit my posts, so I can make improvements or corrections.
  • As a user, I want to be able to delete posts I no longer like.
  • As a user, I want to be able to search posts by entering or selecting a created tag. This will require a Join Statement.

Further Exploration

  • If you're able to get a many-to-many relationship up and running with time to spare, add the functionality to allow visitors to your blog to leave comments. You could also have users comment on comments. Do note that this is challenging, and will require outside research. If you're up for the challenge, check out this article to start.

Airline Planner

Once you've finished the to do list, build an app that allows a user to plan flights from city to city. The user should be able to perform the following actions:

  • Add a city to a list of cities with airline service.
  • Add a flight to a list of flights, with departure time, departure city and arrival destinations included.
  • Change the status of an individual flight to either "On time", "Delayed", "Cancelled" or "Complete".

When we travel by air, our flights are listed by destination city, then listed in order of departure time. Make sure our app displays in the same way. Think about other types of information an airline planner or traveler might want. How could you expand this app?