Schema - ZIP78/instagram-clone- GitHub Wiki

users

column name data type details
id integer not null, primary key
username string not null, indexed, unique
email string not null, indexed, unique
first_name string not null, indexed
last_name string not null, indexed
password_digest string not null
session_token string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
  • index on username, unique: true
  • index on email, unique: true
  • index on first_name
  • index on last_name
  • index on session_token, unique: true

posts

column name data type details
id integer not null, primary key
body text not null
user_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • index on user_id

likes

column name data type details
id integer not null, primary key
user_id integer not null, indexed, foreign key, unique
post_id integer not null, indexed, foreign key, unique
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • post_id references posts
  • index on [:post_id, :user_id], unique: true

comments

column name data type details
id integer not null, primary key
user_id integer not null, indexed, foreign key
comment body not null
post_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • post_id references posts
  • index on [:photo_id, :user_id]

following

column name data type details
id integer not null, primary key
followee_Id integer not null, indexed, foreign key, unique
follower_id integer not null, indexed, foreign key, unique
created_at datetime not null
updated_at datetime not null
  • followee_Id references users
  • post_id references posts
  • index on [:followee_Id, :follower_id], unique: true