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

Rachela
1 min readAug 30, 2021

--

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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Rachela
Rachela

Written by Rachela

I am a librarian and new computer programmer creating an app with Python and Kivy to document the plants in my garden.

No responses yet

Write a response