Skip to content

Database Schema

Renerose Dimatulac edited this page May 21, 2021 · 3 revisions

Database Schema

users

column name data type details
id integer not null, primary key
firstname string(50) not null
lastname string(50) not null
email string(50) not null, unique
hashed_password string binary not null
avatar string(360)
bio text
created_at datetime not null
updated_at datetime not null
  • A user hasMany messages
  • A user hasMany channels

channels

column name data type details
id integer not null, primary key
name string(25) not null, unique
channel_type string(10) not null, default to public
created_at datetime not null
updated_at datetime not null
  • channel_type = public, private, or dm
  • A channel hasMany users
  • A channel hasMany messages

messages

column name data type details
id integer not null, primary key
user_id integer not null, foreign key
channel_id integer not null, foreign key
body text not null
created_at datetime not null
updated_at datetime not null
  • user_id references users(id)
  • channel_id references channels(id)
  • A message belongsTo a user
  • A message belongsTo a channel

subscriptions

column name data type details
id integer not null, primary key
user_id integer not null, foreign key
channel_id integer not null, foreign key
is_starred boolean not null, default to false
created_at datetime not null
updated_at datetime not null
  • user_id references users(id)
  • channel_id references channels(id)

Clone this wiki locally