-
Notifications
You must be signed in to change notification settings - Fork 0
Schema
Micah Jaffe edited this page Dec 11, 2018
·
11 revisions
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 |
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
name |
string | not null, default: Untitled , indexed |
created_at |
datetime | not null |
updated_at |
datetime | not null |
user_id |
integer | not null, foreign key |
-
user_id
referencesusers
table -
name
index should be unique within user scope, i.e. index on[name, user_id] unique
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
title |
string | not null, default: Untitled , indexed |
body |
text | |
created_at |
datetime | not null |
updated_at |
datetime | not null |
notebook_id |
integer | not null, foreign key |
user_id |
integer | not null, foreign key |
-
notebook_id
referencesnotebooks
table. All notes must belong to a notebook.user_id
references theusers
table.
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 betweennotes
andtags
. A note can have zero or more tags. A tag can have zero or more notes (although typically will have at least one). Tags should be unique with the scope of notes and vice-versa, so there should be an index on[note_id, tag_id] unique
.
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
name |
string | not null, indexed |
created_at |
datetime | not null |
updated_at |
datetime | not null |