Skip to content

Database Schema

Yu-Jen Chang edited this page Apr 2, 2018 · 3 revisions

Database Schema

users

column name data type details
id integer not null, primary key
username 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
  • user has_many notes
  • user has_many notebooks

notes

column name data type details
id integer not null, primary key
title string not null, indexed, unique
body string not null
user_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
  • note belongs_to user
  • note belongs_to notebook
  • note has_many taggings

notebooks

column name data type details
id integer not null, primary key
title string not null, indexed, unique
user_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • notebook belongs_to user
  • notebook has_many notes

tags

column name data type details
id integer not null, primary key
name string not null
created_at datetime not null
updated_at datetime not null
  • tags 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
  • taggings belongs_to tag
  • taggings belongs_to note

Clone this wiki locally