Database - HugoEsparzaC/CiCompOverflow GitHub Wiki

ER Diagram

CiCompOverflow Made with dbdiagram

DBML (Database Markup Language)

Table users {
  id_user int [pk, not null, increment]
  nickname varchar(30) [not null, unique]
  email varchar(24) [not null]
  password char(60) [not null]
  picture varchar(200)
  major enum('Computación', 'ISI', 'Otra')
  registration_date date [not null]
  reputation int [not null]
  biography varchar(500)
  status_user enum('Registrado', 'Verificado', 'Bloqueado') [not null]
  admin bool [not null]
  token varchar(15)
}

Ref: users.id_user < questions.id_user

Table questions {
  id_question int [pk, not null, increment]
  id_user int
  title varchar(200) [not null]
  content_question longtext [not null]
  creation_date_question datetime [not null]
  votes_question int [not null]
  status_question enum('Abierta', 'Contestada') [not null]
}

Ref: users.id_user < answers.id_user
Ref: questions.id_question < answers.id_question

Table answers {
  id_answer int [pk, not null, increment]
  id_question int
  id_user int
  content_answer longtext [not null]
  creation_date_answer datetime [not null]
  votes_answer int [not null]
}

Ref: users.id_user < comments.id_user
Ref: questions.id_question < comments.id_question
Ref: answers.id_answer < comments.id_answer

Table comments {
  id_comment int [pk, not null, increment]
  id_question int
  id_answer int
  id_user int
  content_comment longtext [not null]
  date_creation_comment datetime [not null]
}

Ref: users.id_user < votes.id_user
Ref: questions.id_question < votes.id_question
Ref: answers.id_answer < votes.id_answer

Table votes {
  id_vote int [pk, not null, increment]
  id_user int
  id_question int [null]
  id_answer int [null]
  type_vote enum('Positivo', 'Negativo') [not null]
}

Table tags {
  id_tag int [pk, not null, increment]
  name_tag varchar(30) [unique, not null]
}

Ref: questions.id_question < question_tag.id_question
Ref: tags.id_tag < question_tag.id_tag

Table question_tag {
  id_question int [not null]
  id_tag int [not null]
}

Ref: users.id_user < notifications.id_user

Table notifications {
  id_notification int [pk, not null, increment]
  id_user int
  type_notification enum('Answer', 'Comment', 'Reputation') [not null]
  message_notification text [not null]
  date_creation_notification datetime [not null]
  read bool [not null]
}