Skip to content

DB Schema

Nico G Pierson edited this page Aug 20, 2021 · 16 revisions

Database Schema

Users πŸ‘€

column name data type details key
id integer NOT NULL PK
username string NOT NULL
email string NOT NULL, UNIQUE
hashed_password string NOT NULL
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

SQLAlchemy Associations

  • a User has many Recipes
  • a User has many Comments
  • a User has many Likes

Recipes πŸ—’

column name data type details key
id integer NOT NULL PK
img_url string NULL
name string NULL
user_id integer NOT NULL FK
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

SQLAlchemy Associations

  • Recipes belongs to Users
  • Recipes has many Comments

Recipe_ingredients πŸ—’

column name data type details key
id integer NOT NULL PK
ingredient string NOT NULL
measurement string NOT NULL
recipe_id integer NOT NULL FK
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

SQLAlchemy Associations

  • Recipe_ingredients belongs to Recipes

Recipe_directions πŸ—’

column name data type details key
id integer NOT NULL PK
steps integer NOT NULL
directions string NOT NULL
recipe_id integer NOT NULL FK
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

SQLAlchemy Associations

  • Recipe_directions belongs to Recipes

Recipe_photos πŸ“·

column name data type details key
id integer NOT NULL PK
video_url string NULL
img_url string NULL
recipe_id integer NULL FK
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

SQLAlchemy Associations

  • Recipe_photos belongs to Recipes

Comments βœ…

column name data type details key
id integer NOT NULL PK
comment text NULL
user_id integer NOT NULL FK
recipe_id integer NOT NULL FK
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

SQLAlchemy Associations

  • Comments belongs to Users
  • Comments belongs to Recipes

Follows 🀝

column name data type details key
id integer NOT NULL PK
user_id_follow_owner integer NOT NULL FK
user_id_follower integer NOT NULL FK

SQLAlchemy Associations

  • Users has and belongs to many Users

Likes πŸ‘

column name data type details key
id integer NOT NULL PK
user_id integer NOT NULL FK
recipe_id integer NOT NULL FK
created_at timestamp NOT NULL
updated_at timestamp NOT NULL

SQLAlchemy Associations

  • Likes belongs to Users
  • Likes belongs to Recipes