5 Next Steps for Connecting the “Plants” and “Gardens” tables using SQLAlchemy ORM

My app has two tables, Gardens and Plants. When I started, I did not think to include gardens, rather the app was just for documenting plants. However, I quickly realized the user should be able to both search and view plants as well as having more information about the gardens. As a remnant of the start, all of my plants have a “location” column that is not connected to my gardens. Initially, I was also using SQLAlchemy Core. Here are my next steps:

  1. Create a “foreign key” for my Plants table that is the “id” in the Gardens table.
  2. Remove “location” column from the Plants table and instead connect the tables with the “foreign key”.
  3. When searching for plants, the results display this format:
    garden name | location.
    Change it so that the “location” references the “foreign key”.
  4. When deleting gardens, ask the user whether they would like to delete the plants with the garden.
  5. If user does not want to delete the plants, change the plants’ “foreign keys” to 1. This represents a “no garden” location.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store