Schema - ladymicaela/trello-clone GitHub Wiki

users

column name data type details
id integer not null, primary key
username string not null, indexed, unique
email string not null, indexed, unique
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 created_boards
  • has_many boards through board_memberships

boards

column name data type details
id integer not null, primary key
title string not null
creator_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • creator_id references users
  • index on creator_id
  • belongs_to creator
  • has_many members through board_memberships
  • has_many lists
  • has_many cards through lists

lists

column name data type details
id integer not null, primary key
title string not null
board_id integer not null, indexed, foreign key
order integer not null, indexed
created_at datetime not null
updated_at datetime not null
  • board_id references boards
  • index on board_id
  • index on [:order, :board_id], unique: true
  • belongs_to board
  • has_many cards

cards

column name data type details
id integer not null, primary key
title string not null
description text
due_date date
list_id integer not null, indexed, foreign key
order integer not null, indexed
created_at datetime not null
updated_at datetime not null
  • list_id references lists
  • index on list_id
  • index on [:order, :list_id], unique: true
  • belongs_to list
  • has_many comments

comments

column name data type details
id integer not null, primary key
body string not null
author_id integer not null, indexed, foreign key
card_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • author_id references users
  • card_id references cards
  • index on author_id
  • index on card_id
  • belongs_to author
  • belongs_to card

board_memberships

column name data type details
id integer not null, primary key
board_id integer not null, indexed, foreign key
member_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • board_id references boards
  • member_id references users
  • index on [:board_id, :member_id], unique: true
  • belongs_to member
  • belongs_to board