-
Notifications
You must be signed in to change notification settings - Fork 0
Database Schema
Zachary Duvall edited this page Jan 25, 2021
·
48 revisions
Schema for PostgresQL using Sequelize ORM
| Attribute Name | Attribute Type | Constraints |
|---|---|---|
| id | int | not null, primary key |
| username | string | not null, unique, 20 chars or less |
| string | not null, unique, 255 chars or less | |
| hashedPassword | string | not null, STRING.BINARY |
| createdAt | datetime | not null |
| updatedAt | datetime | not null |
- Sequelize
UserhasManymodels.Review - Sequelize
UserhasManymodels.Tree - Sequelize
UserbelongsToManymodels.TreethroughForestConnectionjoin table,otherKey: 'treeId',foreignKey: 'userId'asforestTrees - Sequelize
UserbelongsToManymodels.TreethroughReviewjoin table,otherKey: 'treeId',foreignKey: 'reviewerId'asreviewedTrees
-
hashedPassword- type of STRING.BINARY in sequelize
| Attribute Name | Attribute Type | Constraints |
|---|---|---|
| id | int | not null, primary key |
| name | string | not null, unique, 30 chars or less |
| cityState | string | not null, 40 chars or less |
| detLocation | text | not null, unique |
| coordinates | string | unique, 255 chars or less |
| description | text | not null |
| adderId | int | not null, references Users table |
| createdAt | datetime | not null |
| updatedAt | datetime | not null |
- Sequelize
TreebelongsTomodels.User - Sequelize
TreehasManymodels.Review - Sequelize
TreebelongsToManymodels.UserthroughForestConnectionjoin table,otherKey: 'userId',foreignKey: 'treeId'asforestUsers - Sequelize
TreebelongsToManymodels.UserthroughReviewjoin table,otherKey: 'reviewerId',foreignKey: 'treeId'asreviewAuthors
-
cityStateis for the city and/or state the tree is in (or closest city and/or state) -
detLocationis for a detailed description of where it is -
avgDifficultyfrontend representations: easy, medium, hard, danger -
avgFunFactorfrontend representations: boring, okay, enjoyable, amazing -
avgViewFromTopfrontend representations: dull, good, great, mesmerizing -
coordinatesis a stretch goal
| Attribute Name | Attribute Type | Constraints |
|---|---|---|
| id | int | not null, primary key |
| climbStatus | boolean | not null |
| favStatus | boolean | not null, defaults false |
| userId | int | not null, references Users table |
| treeId | int | not null, references Trees table |
| createdAt | datetime | not null |
| updatedAt | datetime | not null |
- This is the
User-Treejoin table, associations are taken care of in those associations
-
climbStatusfrontend representations:true= "climbed",false= "want to climb" - Stretch goal:
favStatusis available to toggle after a tree is in your forest- Frontend representations:
true= "favorite", false = "no indication"
- Frontend representations:
| Attribute Name | Attribute Type | Constraints |
|---|---|---|
| id | int | not null, primary key |
| reviewText | text | |
| treeId | int | not null, references Trees table |
| reviewerId | int | not null, references Users table |
| difficulty | int | not null, 1 - 4 |
| funFactor | int | not null, 1 - 4 |
| viewFromTop | int | not null, 1 - 4 |
| createdAt | datetime | not null |
| updatedAt | datetime | not null |
- Sequelize
ReviewbelongsTomodels.User - Sequelize
ReviewbelongsTomodels.Tree
-
difficultyfrontend representations in form dropdown: easy, medium, hard, danger -
funFactorfrontend representations in form dropdown: boring, okay, enjoyable, amazing -
viewFromTopfrontend representations in form dropdown: dull, good, great, mesmerizing