Skip to content

Instantly share code, notes, and snippets.

@mugan86
Created December 1, 2019 07:53
Show Gist options
  • Save mugan86/b91e6cdfaab8da04907cdda743f65c68 to your computer and use it in GitHub Desktop.
Save mugan86/b91e6cdfaab8da04907cdda743f65c68 to your computer and use it in GitHub Desktop.
Sistema de preguntas y respuestas
create table users(
id int not null primary key,
name varchar(50) not null,
lastname varchar(50) not null,
username varchar(50),
email varchar(255) not null,
password varchar(60) not null,
image varchar(255) not null,
is_active boolean not null,
is_admin boolean not null,
created_at timestamp not null
);
create table category(
id int not null primary key,
name varchar(50)
);
create table question(
id int not null primary key,
title varchar(255),
description text,
tags varchar(255),
user_id int not null,
category_id int,
is_solved boolean not null,
created_at timestamp not null,
foreign key (user_id) references users(id),
foreign key (category_id) references category(id)
);
create table answer(
id int not null primary key,
description text,
user_id int not null,
question_id int,
is_correct boolean not null,
created_at timestamp not null,
foreign key (user_id) references users(id),
foreign key (question_id) references question(id)
);
create table vote(
id int not null primary key,
kind_id int, /** 1.- question, 2.- answer **/
ref_id int,
val int not null,
created_at timestamp not null,
user_id int not null,
foreign key (user_id) references users(id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment