-
Notifications
You must be signed in to change notification settings - Fork 0
Database Schema
Scott A. Smith edited this page Nov 25, 2020
·
9 revisions
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
username |
string(50) | not null, unique |
email |
string(50) | not null, unique |
hashedPassword |
binary string | not null |
goBy |
string(50) | |
picture |
string(255) | |
gender |
enum | values: Male, Female, Other |
mentorDesc |
text | |
mentorIsPublic |
bool | not null, default false |
menteeIsPublic |
bool | not null, default false |
menteeDesc |
text | |
createdAt |
datetime | not null |
updatedAt |
datetime | not null |
-
unique index on
username
-
unique index on
email
-
Sequelize
belongsToMany
Users
associations throughConnections
; NOTE:foreignKey
should point to theid
of the perspective of theUser
being examined for the relationship, so1. for Mentoring someone else, "I" (my
id
) is theforeignKey
and in that relation is in thementorId
position on theConnections
table, while who I am mentoring is theotherKey
set to that other user'suserId
, then2. for who is a Mentor of "me" (my
id
), again, is theforeignKey
and in that relation is in theuserId
position on theConnections
table, while who is my Mentor is theotherKey
and has theirid
in thementorId
position of the table. Here is the example layout of that relation:User.belongsToMany(models.Users, {through: "Connections", as: "mentoring", foreignKey: "mentorId", otherKey: "userId"}); User.belongsToMany(models.Users, {through: "Connections", as: "learning", foreignKey: "userId", otherKey: "mentorId"});
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
userId |
integer | not null, foreign key |
mentorId |
integer | not null, foreign key |
status |
enum | values: 'pending', 'established', 'rejected' |
initiatorId |
integer | not null |
createdAt |
datetime | not null |
updatedAt |
datetime | not null |
- The
initiatorId
is the user to first make the pending request for a connection. - Sequelize
hasMany
Discussions
association - Sequelize
hasMany
Goals
association
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
connectionId |
integer | not null, foreign key |
title |
string(255) | not null |
stream |
json | not null /object of posts/ |
createdAt |
datetime | not null |
updatedAt |
datetime | not null |
- Sequelize
belongsTo
Connections
association
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
connectionId |
integer | not null, foreign key |
title |
string(50) | not null |
summary |
string(255) | |
stepsList |
json | |
achievement |
float | min 0 max 100 |
createdAt |
datetime | not null |
updatedAt |
datetime | not null |
- Sequelize
belongsTo
Connections
association