Skip to content
imshentastic edited this page Dec 11, 2019 · 19 revisions

Database Schema

users

Column Name Data Type Details
id integer not null, primary key
email string not null, indexed, unique
password_digest string not null
full_name string
session_token string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
  • index on email, unique: true
  • index on session_token, unique: true
  • full_name is null (only require email and password for signup)

notes

Column Name Data Type Details
id integer not null, primary key
heading string
body string
notebook_id integer indexed, foreign key
starred boolean
created_at datetime not null
updated_at datetime not null
trashed boolean
  • index on notebook_id
  • starred, default = false
  • trashed, default = false, until true deletion of note

notebooks

Column Name Data Type Details
id integer not null, primary key
title string
user_id integer not null, indexed, foreign key
starred boolean
created_at datetime not null
updated_at datetime not null
default boolean
trashed boolean
  • index on user_id
  • starred, default = false
  • notebook.default is a boolean that indicates whether notebook can be deleted (first notebook cannot be deleted)
  • trashed, default = false, until true deletion of notebook

tags

Column Name Data Type Details
id integer not null, primary key
note_id integer not null, indexed, foreign key
hashtag string not null
starred boolean
created_at datetime not null
updated_at datetime not null
  • starred, default = false
  • tags can be trashed, but unlike notes and notebooks, are immediately deleted (cannot be restored)

tagged notes

Column Name Data Type Details
id integer not null, primary key
note_id integer not null, indexed, foreign key
tag_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • joins_table between tags and notes

Clone this wiki locally