DB Schema - RayC206/Rayddit GitHub Wiki

Database Schema

Table users {
  id int [pk]
  username varchar
  email varchar
  password varchar
  profile_image varchar
  created_at datetime
  updated_at datetime
}

Table posts {
  id int [pk]
  title varchar
  img_url varchar
  text varchar
  link_url varchar
  user_id int 
  subreddit_id int
  post_type_id int
  created_at datetime
  updated_at datetime
}

Table post_types {
  id int [pk]
  type varchar
  created_at datetime
  updated_at datetime
}

Table subreddits {
  id int [pk]
  name varchar
  description text
  icon_url varchar
  created_at datetime
  updated_at datetime
}

Table subscriptions {
  id int [pk]
  subreddit_id int
  user_id int
}

Table votes {
  id int [pk]
  user_id int
  post_id int
  value int
}



Ref: "subreddits"."id" < "posts"."subreddit_id"

Ref: "users"."id" < "posts"."user_id"


Ref: "post_types"."id" < "posts"."post_type_id"

Ref: "subreddits"."id" < "subscriptions"."subreddit_id"

Ref: "users"."id" < "subscriptions"."user_id"

Ref: "posts"."id" < "votes"."post_id"

Ref: "users"."id" < "votes"."user_id"