Skip to content
Anton James edited this page May 19, 2023 · 8 revisions

Postgres Database Schema

users

column name data type details
id bigint not null, primary key
username string not null, indexed, unique
email string not null, indexed, unique
games_owned string not null
password_digest string not null
session_token string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
  • index on username, unique: true
  • index on email, unique: true
  • index on session_token, unique: true
  • has_many :games
  • has_many :reviews

games

column name data type details
id bigint not null, primary key
title string not null, indexed, unique
price float not null
genre string not null
rating integer not null, indexed
details text not null
created_at datetime not null
updated_at datetime not null
  • index on title, unique: true
  • index on rating
  • has_many :reviews

cart

column name data type details
id bigint not null, primary key
user_id string not null, indexed, unique
game_id float not null
created_at datetime not null
updated_at datetime not null
  • user_id reference to user
  • game_id reference to game
  • has_many :games
  • belongs_to :user

review

column name data type details
id bigint not null, primary key
user_id string not null, indexed, unique
game_id float not null
rating integer not null
comment text not null
created_at datetime not null
updated_at datetime not null
  • user_id reference to user
  • game_id reference to game
  • belongs_to :game
  • belongs_to :user

Clone this wiki locally