Skip to content
aaxzheng edited this page Nov 7, 2018 · 5 revisions

Database 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

notes

column name data type details
id integer not null, primary key
body string not null
user_id integer not null, indexed, foreign key
tag_id integer indexed, foreign key
notebook_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references the user
  • tag_id references any tags that are added to the notes
  • notebook_id references the notebook that the note belongs to.

notebooks

column name data type details
id integer not null, primary key
title string not null
user_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references the user
  • title is the name of the notebook

tags

column name data type details
id integer not null, primary key
tag string not null
user_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references the user
  • tag is the name of the tag

Clone this wiki locally