This video is available to students only

Database Relationships and Migrations in a Flask App

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

DB Relationships & Migrations

Right now we have two models, Product and User. To build out a store front and process orders, we'll need at least one more model: Store. We can also add an Order model if we want to track orders.

Each User needs to be able to manage one Store. Each Store will have multiple Products. Every Order will have one Product.

This data model is relational, but neither our database nor our models currently reflect that. For example, there is no way to denote that a Product was created by a specific User.

This lesson preview is part of the Fullstack Flask: Build a Complete SaaS App with Flask course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

Unlock This Course

Get unlimited access to Fullstack Flask: Build a Complete SaaS App with Flask, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course Fullstack Flask: Build a Complete SaaS App with Flask