Skip to content

Database Schema

Walter Hills edited this page Feb 20, 2021 · 16 revisions

Schema for PostgreSQL using Sequelize ORM

Users

column name data type details
id varchar(36) not null, indexed, primary key
first_name varchar(20) not null
last_name varchar(20) not null
email varchar(255) not null, unique
hashedPassword binary not null
bio text not null
username varchar(20) not null, unique
createdAt datetime not null
updatedAt datetime not null
  • Sequelize hasMany comments association
  • Sequelize hasMany videos association

Comments

column name data type details
id integer not null, primary key
body text not null
userId integer not null
videoId integer not null
createdAt datetime not null
updatedAt datetime not null
  • Sequelize belongsTo users association
  • Sequelize belongsTo videos association

Videos

column name data type details
id integer not null, primary key
title varchar(30) not null
description text not null
link varchar(50) unique, not null
languageId integer not null
userId integer not null
createdAt datetime not null
updatedAt datetime not null
  • Sequelize hasMany comments association
  • Sequelize belongsTo users association
  • Sequelize belongsTo languagesassociation

Languages

column name data type details
id integer not null, primary key
name varchar(20) unique, not null
  • Sequelize hasMany videos association

Migration order: Users-> Language -> Videos -> Comments

Clone this wiki locally