Skip to content

Database Schema

Scott A. Smith edited this page Nov 25, 2020 · 9 revisions

Users table

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 through Connections; NOTE: foreignKey should point to the id of the perspective of the User being examined for the relationship, so

    1. for Mentoring someone else, "I" (my id) is the foreignKey and in that relation is in the mentorId position on the Connections table, while who I am mentoring is the otherKey set to that other user's userId, then

    2. for who is a Mentor of "me" (my id), again, is the foreignKey and in that relation is in the userId position on the Connections table, while who is my Mentor is the otherKey and has their id in the mentorId 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"});
    

Connections table

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

Discussions table

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

Goals table

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
Clone this wiki locally