Skip to content
Micah Jaffe edited this page Dec 6, 2018 · 11 revisions

Database Schema

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

notebooks

column name data type details
id integer not null, primary key
name string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
user_id integer not null, foreign key
  • user_id references users table

notes

column name data type details
id integer not null, primary key
title string indexed, default: 'Untitled
body text
created_at datetime not null
updated_at datetime not null
notebook_id integer not null, foreign key
  • notebook_id references notebooks table. All notes must belong to a notebook. user_id can be recovered via notebook.

note_tags

column name data type details
id integer not null, primary key
note_id integer not null, foreign key
tag_id integer not null, foreign key
created_at datetime not null
updated_at datetime not null
  • note_tags is a joins table for the many-to-many relationship between notes and tags. A note can have zero or more tags. A tag can have zero or more notes (although typically will have at least one).

tags

column name data type details
id integer not null, primary key
name string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
Clone this wiki locally