Skip to content
aaxzheng edited this page Nov 14, 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 text 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
  • user_id references the user
  • 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

note_tags

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
  • This is a join table that connects tags and notes in a many to many relationship
  • note_id belongs to a note and tag_id belongs to a tag

Clone this wiki locally