-
Notifications
You must be signed in to change notification settings - Fork 1
schema
imshentastic edited this page Dec 12, 2019
·
19 revisions
| Column Name | Data Type | Details |
|---|---|---|
| id | integer | not null, primary key |
| 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)
| 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
| 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
| Column Name | Data Type | Details |
|---|---|---|
| id | integer | not null, primary key |
| user_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)
- users have notebooks that may have notes which may have tags (users and notes have through association)
- tags can be created without a note or notebook (users and tags have direct relationship)
| 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
- many to many relationship between tags and notes