Skip to content
Jonathan Bae edited this page Sep 27, 2019 · 11 revisions

Schema

users


column name data type details
id integer not null, primary key
username string not null, indexed
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 session_token, unique: true
  • has_many :notebooks
  • has_many :notes
  • has_many :tags

notebooks


column name data type details
id integer not null, primary key
title string not null, indexed
author_id integer not null, indexed, foreign_key
created_at datetime not null
updated_at datetime not null
  • index on author_id
  • belongs_to :user
  • has_many :notes

notes


column name data type details
id integer not null, primary key
title string not null, indexed
content text not null
author_id integer not null, indexed, foreign_key
notebook_id integer not null, indexed, foreign_key
created_at datetime not null
updated_at datetime not null
  • index on author_id
  • index on notebook_id
  • belongs_to :user
  • belongs_to :notebook
  • has_many :taggings

tags


column name data type details
id integer not null, primary key
name string not null, indexed
created_at datetime not null
updated_at datetime not null
  • has_many :taggings

taggings


column name data type details
id integer not null, primary key
tag_id integer not null, indexed, foreign_key
note_id integer not null, indexed, foreign_key
created_at datetime not null
updated_at datetime not null
  • index on tag_id, note_id, unique: true
  • belongs_to :tag
  • belongs_to :note

Clone this wiki locally