--
-- PostgreSQL database dump
--

-- Dumped from database version 9.6.9
-- Dumped by pg_dump version 9.6.9

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: dysu_answer_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_answer_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_answer_id_seq OWNER TO postgres;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: dysu_answer; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dysu_answer (
    id integer DEFAULT nextval('public.dysu_answer_id_seq'::regclass) NOT NULL,
    field_id integer NOT NULL,
    register_id integer NOT NULL,
    field_value jsonb NOT NULL,
    register_date timestamp without time zone NOT NULL,
    sonata_id integer NOT NULL
);


ALTER TABLE public.dysu_answer OWNER TO postgres;

--
-- Name: TABLE dysu_answer; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dysu_answer IS 'Tabla que contiene la informacion diligenciada en las encuestas';


--
-- Name: COLUMN dysu_answer.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer.id IS 'Identificador unico de los registros';


--
-- Name: COLUMN dysu_answer.field_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer.field_id IS 'Identificador que relaciona las respuesta con el campo diligenciado';


--
-- Name: COLUMN dysu_answer.register_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer.register_id IS 'Identificador que agrupa las respuestas digitadas en la encuesta';


--
-- Name: COLUMN dysu_answer.field_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer.field_value IS 'Texto digitado en la encuesta';


--
-- Name: COLUMN dysu_answer.register_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer.register_date IS 'Fecha en la que se registro la informacion';


--
-- Name: COLUMN dysu_answer.sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer.sonata_id IS 'Identificador del usuario que digita la informacion en el campo';


--
-- Name: dysu_answer_aud_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_answer_aud_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_answer_aud_id_seq OWNER TO postgres;

--
-- Name: dysu_answer_aud; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dysu_answer_aud (
    id integer DEFAULT nextval('public.dysu_answer_aud_id_seq'::regclass) NOT NULL,
    answer_id integer NOT NULL,
    field_id integer NOT NULL,
    register_id integer NOT NULL,
    field_value jsonb NOT NULL,
    register_date timestamp without time zone NOT NULL,
    edit_date timestamp without time zone NOT NULL,
    sonata_id integer NOT NULL,
    first_sonata_id integer NOT NULL
);


ALTER TABLE public.dysu_answer_aud OWNER TO postgres;

--
-- Name: TABLE dysu_answer_aud; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dysu_answer_aud IS 'Tabla de auditoria que contiene la informacion diligenciada en las encuestas';


--
-- Name: COLUMN dysu_answer_aud.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer_aud.id IS 'Identificador unico de la tabla';


--
-- Name: COLUMN dysu_answer_aud.answer_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer_aud.answer_id IS 'Identificador de la respuesta diligenciada en la encuesta';


--
-- Name: COLUMN dysu_answer_aud.field_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer_aud.field_id IS 'Identificador que relaciona las respuesta con el campo diligenciado';


--
-- Name: COLUMN dysu_answer_aud.register_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer_aud.register_id IS 'Identificador que agrupa las respuestas digitadas en la encuesta';


--
-- Name: COLUMN dysu_answer_aud.field_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer_aud.field_value IS 'Texto digitado en la encuesta';


--
-- Name: COLUMN dysu_answer_aud.register_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer_aud.register_date IS 'Fecha en la que se realizo el registro la primera vez';


--
-- Name: COLUMN dysu_answer_aud.edit_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer_aud.edit_date IS 'Fecha en la que se modifico el registro';


--
-- Name: COLUMN dysu_answer_aud.sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer_aud.sonata_id IS 'Identificador del usuario quien realiza la modificacion';


--
-- Name: COLUMN dysu_answer_aud.first_sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_answer_aud.first_sonata_id IS 'Identificador del usuario quien realizo el registro la primera vez';


--
-- Name: dysu_field; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dysu_field (
    id integer NOT NULL,
    form_id integer NOT NULL,
    field_label character varying(500),
    field_description character varying(500),
    field_type character varying(50) NOT NULL,
    field_required smallint DEFAULT 0 NOT NULL,
    field_recurrent smallint DEFAULT 0 NOT NULL,
    field_order integer DEFAULT 0 NOT NULL,
    register_date timestamp without time zone DEFAULT now() NOT NULL,
    state smallint DEFAULT 1 NOT NULL,
    sonata_id integer NOT NULL,
    field_min real DEFAULT 0 NOT NULL,
    field_max real DEFAULT 0 NOT NULL
);


ALTER TABLE public.dysu_field OWNER TO postgres;

--
-- Name: TABLE dysu_field; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dysu_field IS 'Tabla que contiene los campos creados para la encuesta';


--
-- Name: COLUMN dysu_field.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.id IS 'Identificador unico del registro';


--
-- Name: COLUMN dysu_field.form_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.form_id IS 'Identificador de la encuesta a la cual esta asociado el campo';


--
-- Name: COLUMN dysu_field.field_label; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.field_label IS 'Etiqueta del campo creado para la encuesta';


--
-- Name: COLUMN dysu_field.field_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.field_type IS 'Tipo de campo que se esta creando para la encuesta';


--
-- Name: COLUMN dysu_field.field_required; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.field_required IS 'Indica si el campo creado es obligatorio 1=> Obligatorio; 0=> No obligatorio';


--
-- Name: COLUMN dysu_field.field_recurrent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.field_recurrent IS 'Indica si un campo es recurrente; 1=> Recurrente; 0=> No recurrente';


--
-- Name: COLUMN dysu_field.field_order; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.field_order IS 'Indica el orden en que se deben mostrar los campos en la encuesta';


--
-- Name: COLUMN dysu_field.register_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.register_date IS 'Fecha en la que realiza el registro';


--
-- Name: COLUMN dysu_field.state; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.state IS 'Estado de la encuesta 1=> Activo; 0=> Inactivo';


--
-- Name: COLUMN dysu_field.sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.sonata_id IS 'Identificador de la persona que realiza el registro';


--
-- Name: COLUMN dysu_field.field_min; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.field_min IS 'Campo que indica el numero minimo de registros a ingresar en el campo';


--
-- Name: COLUMN dysu_field.field_max; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field.field_max IS 'Numero maximo de caracteres que se admitiran en un campo';


--
-- Name: dysu_field_aud; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dysu_field_aud (
    field_id integer NOT NULL,
    form_id integer NOT NULL,
    field_label character varying(500),
    field_description character varying(500),
    field_type character varying(50) NOT NULL,
    field_required smallint DEFAULT 1 NOT NULL,
    field_recurrent smallint DEFAULT 0 NOT NULL,
    field_order integer DEFAULT 0 NOT NULL,
    field_min real DEFAULT 0 NOT NULL,
    field_max real DEFAULT 0 NOT NULL,
    register_date timestamp without time zone DEFAULT now() NOT NULL,
    edit_date timestamp without time zone DEFAULT now() NOT NULL,
    state smallint DEFAULT 1 NOT NULL,
    sonata_id integer NOT NULL,
    first_sonata_id integer NOT NULL,
    id integer NOT NULL
);


ALTER TABLE public.dysu_field_aud OWNER TO postgres;

--
-- Name: TABLE dysu_field_aud; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dysu_field_aud IS 'Tabla de auditoria que contiene los campos creados para la encuesta';


--
-- Name: COLUMN dysu_field_aud.field_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.field_id IS 'Identificador del campo registrado';


--
-- Name: COLUMN dysu_field_aud.form_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.form_id IS 'Identificador de la encuesta a la cual esta asociado el campo';


--
-- Name: COLUMN dysu_field_aud.field_label; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.field_label IS 'Etiqueta del campo creado para la encuesta';


--
-- Name: COLUMN dysu_field_aud.field_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.field_description IS 'Texto con la descripcion del campo';


--
-- Name: COLUMN dysu_field_aud.field_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.field_type IS 'Tipo de campo que se esta creando para la encuesta';


--
-- Name: COLUMN dysu_field_aud.field_required; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.field_required IS 'Estado de la encuesta 1=> Activo; 0=> Inactivo';


--
-- Name: COLUMN dysu_field_aud.field_recurrent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.field_recurrent IS 'Indica si un campo es recurrente; 1=> Recurrente; 0=> No recurrente';


--
-- Name: COLUMN dysu_field_aud.field_order; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.field_order IS 'Indica el orden en que se deben mostrar los campos en la encuesta';


--
-- Name: COLUMN dysu_field_aud.field_min; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.field_min IS 'Indica el numero minimo de caracteres';


--
-- Name: COLUMN dysu_field_aud.field_max; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.field_max IS 'Indica el numero maximo de caracteres';


--
-- Name: COLUMN dysu_field_aud.register_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.register_date IS 'Fecha en la que realiza el registro';


--
-- Name: COLUMN dysu_field_aud.edit_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.edit_date IS 'Fecha en la que realiza el registro';


--
-- Name: COLUMN dysu_field_aud.state; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.state IS 'Estado de la encuesta 1=> Activo; 0=> Inactivo';


--
-- Name: COLUMN dysu_field_aud.sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.sonata_id IS 'Identificador del usuario quien realizo la modificacion';


--
-- Name: COLUMN dysu_field_aud.first_sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.first_sonata_id IS 'Identificador del usuario quien realizo el registro antes de ser modificado';


--
-- Name: COLUMN dysu_field_aud.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_field_aud.id IS 'Identificador unico del registro';


--
-- Name: dysu_field_aud_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_field_aud_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_field_aud_id_seq OWNER TO postgres;

--
-- Name: dysu_field_aud_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.dysu_field_aud_id_seq OWNED BY public.dysu_field_aud.id;


--
-- Name: dysu_field_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_field_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_field_id_seq OWNER TO postgres;

--
-- Name: dysu_field_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.dysu_field_id_seq OWNED BY public.dysu_field.id;


--
-- Name: dysu_form; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dysu_form (
    id integer NOT NULL,
    form_name character varying(200) NOT NULL,
    modality_id character varying(10) NOT NULL,
    state smallint DEFAULT 1 NOT NULL,
    register_date timestamp without time zone DEFAULT now() NOT NULL,
    sonata_id integer NOT NULL
);


ALTER TABLE public.dysu_form OWNER TO postgres;

--
-- Name: TABLE dysu_form; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dysu_form IS 'Tabla para almacenar la informacion general de la encuesta';


--
-- Name: COLUMN dysu_form.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form.id IS 'Identificador unico del registro';


--
-- Name: COLUMN dysu_form.form_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form.form_name IS 'Nombre de la encuesta';


--
-- Name: COLUMN dysu_form.modality_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form.modality_id IS 'Identificador de la modalidad a la cual se encuentra asociada la encuesta';


--
-- Name: COLUMN dysu_form.state; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form.state IS 'Estado de la encuesta 1=> Activo; 0=> Inactivo';


--
-- Name: COLUMN dysu_form.register_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form.register_date IS 'Fecha en la que se realiza el registro';


--
-- Name: COLUMN dysu_form.sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form.sonata_id IS 'Campo que guarda el identificador del usuario que realizo el registro';


--
-- Name: dysu_form_aud; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dysu_form_aud (
    id integer NOT NULL,
    form_id integer NOT NULL,
    form_name character varying(200) NOT NULL,
    modality_id character varying(10) NOT NULL,
    register_date timestamp without time zone DEFAULT now() NOT NULL,
    edit_date timestamp without time zone DEFAULT now() NOT NULL,
    sonata_id integer NOT NULL,
    state smallint DEFAULT 1 NOT NULL,
    first_sonata_id integer NOT NULL
);


ALTER TABLE public.dysu_form_aud OWNER TO postgres;

--
-- Name: TABLE dysu_form_aud; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dysu_form_aud IS 'Tabla de auditoria que contiene la informacion general de la encuesta';


--
-- Name: COLUMN dysu_form_aud.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form_aud.id IS 'Identificador unico del registro';


--
-- Name: COLUMN dysu_form_aud.form_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form_aud.form_id IS 'Identificador del formulario';


--
-- Name: COLUMN dysu_form_aud.form_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form_aud.form_name IS 'Nombre de la encuesta';


--
-- Name: COLUMN dysu_form_aud.modality_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form_aud.modality_id IS 'Identificador de la modalidad a la cual se encuentra asociada la encuesta';


--
-- Name: COLUMN dysu_form_aud.register_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form_aud.register_date IS 'Fecha en la que es realizado el registro';


--
-- Name: COLUMN dysu_form_aud.edit_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form_aud.edit_date IS 'Fecha en la que se modifico el registro';


--
-- Name: COLUMN dysu_form_aud.sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form_aud.sonata_id IS 'Identificador del usuario que realizo el cambio';


--
-- Name: COLUMN dysu_form_aud.state; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form_aud.state IS 'Estado de la encuesta 1=> Activo; 0=> Inactivo';


--
-- Name: COLUMN dysu_form_aud.first_sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_form_aud.first_sonata_id IS 'Identificador de la persona que realizo el registro la primera vez';


--
-- Name: dysu_form_aud_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_form_aud_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_form_aud_id_seq OWNER TO postgres;

--
-- Name: dysu_form_aud_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.dysu_form_aud_id_seq OWNED BY public.dysu_form_aud.id;


--
-- Name: dysu_form_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_form_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_form_id_seq OWNER TO postgres;

--
-- Name: dysu_form_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.dysu_form_id_seq OWNED BY public.dysu_form.id;


--
-- Name: dysu_list_answers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dysu_list_answers (
    id integer NOT NULL,
    field_id integer NOT NULL,
    answer_value character varying(500) NOT NULL,
    answer_state smallint DEFAULT 1 NOT NULL,
    answer_order integer DEFAULT 1 NOT NULL,
    register_date timestamp without time zone DEFAULT now() NOT NULL,
    sonata_id integer DEFAULT 1 NOT NULL
);


ALTER TABLE public.dysu_list_answers OWNER TO postgres;

--
-- Name: TABLE dysu_list_answers; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dysu_list_answers IS 'Tabla que contiene las opciones para un select, radioButton, checkbox, etc';


--
-- Name: COLUMN dysu_list_answers.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers.id IS 'Identificador unico del registro';


--
-- Name: COLUMN dysu_list_answers.field_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers.field_id IS 'Identificador del campo al cual pertenecen la lista de respuestas';


--
-- Name: COLUMN dysu_list_answers.answer_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers.answer_value IS 'Texto de la respuesta ';


--
-- Name: COLUMN dysu_list_answers.answer_state; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers.answer_state IS 'Estado de la respuesta 1=> Activo; 0=> Inactivo';


--
-- Name: COLUMN dysu_list_answers.answer_order; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers.answer_order IS 'Orden de las opciones';


--
-- Name: COLUMN dysu_list_answers.register_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers.register_date IS 'Fecha en la que se realizo el registro';


--
-- Name: COLUMN dysu_list_answers.sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers.sonata_id IS 'Identificador del usuario que realizo el registro';


--
-- Name: dysu_list_answers_aud; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dysu_list_answers_aud (
    id integer NOT NULL,
    list_answers_id integer NOT NULL,
    field_id integer NOT NULL,
    answer_value character varying(500) NOT NULL,
    answer_state smallint DEFAULT 1 NOT NULL,
    answer_order integer DEFAULT 1 NOT NULL,
    register_date timestamp without time zone DEFAULT now() NOT NULL,
    edit_date timestamp without time zone DEFAULT now() NOT NULL,
    sonata_id integer NOT NULL,
    first_sonata_id integer NOT NULL
);


ALTER TABLE public.dysu_list_answers_aud OWNER TO postgres;

--
-- Name: TABLE dysu_list_answers_aud; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dysu_list_answers_aud IS 'Tabla de auditoria que contiene las opciones para un select, radioButton, checkbox, etc';


--
-- Name: COLUMN dysu_list_answers_aud.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers_aud.id IS 'Identificador unico del registro';


--
-- Name: COLUMN dysu_list_answers_aud.list_answers_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers_aud.list_answers_id IS 'Identificador de la lista de respuestas';


--
-- Name: COLUMN dysu_list_answers_aud.field_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers_aud.field_id IS 'Identificador del campo al cual pertenecen la lista de respuestas';


--
-- Name: COLUMN dysu_list_answers_aud.answer_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers_aud.answer_value IS 'Texto de la respuesta';


--
-- Name: COLUMN dysu_list_answers_aud.answer_state; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers_aud.answer_state IS 'Estado de la respuesta 1=> Activo; 0=> Inactivo';


--
-- Name: COLUMN dysu_list_answers_aud.answer_order; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers_aud.answer_order IS 'Orden de las opciones';


--
-- Name: COLUMN dysu_list_answers_aud.register_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers_aud.register_date IS 'Fecha en la que se realizo el registro';


--
-- Name: COLUMN dysu_list_answers_aud.edit_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers_aud.edit_date IS 'Fecha en la que se modifico el registro';


--
-- Name: COLUMN dysu_list_answers_aud.sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers_aud.sonata_id IS 'Identificador del usuario quien realizo la modificacion';


--
-- Name: COLUMN dysu_list_answers_aud.first_sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_list_answers_aud.first_sonata_id IS 'Identificador del usuario quien realizo la modificacion';


--
-- Name: dysu_list_answers_aud_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_list_answers_aud_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_list_answers_aud_id_seq OWNER TO postgres;

--
-- Name: dysu_list_answers_aud_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.dysu_list_answers_aud_id_seq OWNED BY public.dysu_list_answers_aud.id;


--
-- Name: dysu_list_answers_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_list_answers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_list_answers_id_seq OWNER TO postgres;

--
-- Name: dysu_list_answers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.dysu_list_answers_id_seq OWNED BY public.dysu_list_answers.id;


--
-- Name: dysu_register; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dysu_register (
    id integer NOT NULL,
    form_id integer NOT NULL,
    appointment_code character varying(10) NOT NULL,
    register_date timestamp without time zone DEFAULT now() NOT NULL,
    sonata_id integer NOT NULL,
    state smallint DEFAULT 1,
    person_id uuid NOT NULL
);


ALTER TABLE public.dysu_register OWNER TO postgres;

--
-- Name: TABLE dysu_register; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dysu_register IS 'Tabla que contiene la informacion basica del registro relacionado a la encuesta contestada';


--
-- Name: COLUMN dysu_register.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register.id IS 'Identificador unico del registro';


--
-- Name: COLUMN dysu_register.form_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register.form_id IS 'Identificador de la encuesta que se esta contestando';


--
-- Name: COLUMN dysu_register.appointment_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register.appointment_code IS 'Codigo del paciente';


--
-- Name: COLUMN dysu_register.register_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register.register_date IS 'Fecha en la que se realizar el registro';


--
-- Name: COLUMN dysu_register.sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register.sonata_id IS 'Usuario que diligencia la encuesta';


--
-- Name: COLUMN dysu_register.state; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register.state IS 'Estado en el que se encuentra el registro con el fin de indicar si se pude modifcar o no 1=> Activo para modificacion 0=> Inactivo para modificacion';


--
-- Name: COLUMN dysu_register.person_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register.person_id IS 'Identificador del paciente';


--
-- Name: dysu_register_aud; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dysu_register_aud (
    id integer NOT NULL,
    register_id integer NOT NULL,
    form_id integer NOT NULL,
    appointment_code character(10) NOT NULL,
    register_date timestamp without time zone NOT NULL,
    edit_date timestamp without time zone DEFAULT now() NOT NULL,
    person_id uuid NOT NULL,
    sonata_id integer NOT NULL,
    first_sonata_id integer NOT NULL,
    state smallint DEFAULT 1 NOT NULL
);


ALTER TABLE public.dysu_register_aud OWNER TO postgres;

--
-- Name: TABLE dysu_register_aud; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dysu_register_aud IS 'Tabla de auditoria para la tabla dysu_register';


--
-- Name: COLUMN dysu_register_aud.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register_aud.id IS 'Identificador unico del registro';


--
-- Name: COLUMN dysu_register_aud.register_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register_aud.register_id IS 'Identificador del registro';


--
-- Name: COLUMN dysu_register_aud.form_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register_aud.form_id IS 'Identificador de la encuesta';


--
-- Name: COLUMN dysu_register_aud.appointment_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register_aud.appointment_code IS 'Codigo de la cita';


--
-- Name: COLUMN dysu_register_aud.register_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register_aud.register_date IS 'Fecha en la que se realizo el registro';


--
-- Name: COLUMN dysu_register_aud.edit_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register_aud.edit_date IS 'Fecha en la que se edito el registro';


--
-- Name: COLUMN dysu_register_aud.person_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register_aud.person_id IS 'Identificador del paciente';


--
-- Name: COLUMN dysu_register_aud.sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register_aud.sonata_id IS 'Identificador de la persona que modifica el registro';


--
-- Name: COLUMN dysu_register_aud.first_sonata_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register_aud.first_sonata_id IS 'Identificador de la persona que realiza el registro';


--
-- Name: COLUMN dysu_register_aud.state; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dysu_register_aud.state IS 'Estado en el que se encuentra el registro con el fin de indicar si se puede modificar o no 1 => Activo para modificacion 0 => Inactivo para modificacion';


--
-- Name: dysu_register_aud_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_register_aud_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_register_aud_id_seq OWNER TO postgres;

--
-- Name: dysu_register_aud_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.dysu_register_aud_id_seq OWNED BY public.dysu_register_aud.id;


--
-- Name: dysu_register_form_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_register_form_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_register_form_id_seq OWNER TO postgres;

--
-- Name: dysu_register_form_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.dysu_register_form_id_seq OWNED BY public.dysu_register.form_id;


--
-- Name: dysu_register_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.dysu_register_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.dysu_register_id_seq OWNER TO postgres;

--
-- Name: dysu_register_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.dysu_register_id_seq OWNED BY public.dysu_register.id;


--
-- Name: dysu_field id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_field ALTER COLUMN id SET DEFAULT nextval('public.dysu_field_id_seq'::regclass);


--
-- Name: dysu_field_aud id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_field_aud ALTER COLUMN id SET DEFAULT nextval('public.dysu_field_aud_id_seq'::regclass);


--
-- Name: dysu_form id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_form ALTER COLUMN id SET DEFAULT nextval('public.dysu_form_id_seq'::regclass);


--
-- Name: dysu_form_aud id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_form_aud ALTER COLUMN id SET DEFAULT nextval('public.dysu_form_aud_id_seq'::regclass);


--
-- Name: dysu_list_answers id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_list_answers ALTER COLUMN id SET DEFAULT nextval('public.dysu_list_answers_id_seq'::regclass);


--
-- Name: dysu_list_answers_aud id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_list_answers_aud ALTER COLUMN id SET DEFAULT nextval('public.dysu_list_answers_aud_id_seq'::regclass);


--
-- Name: dysu_register id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_register ALTER COLUMN id SET DEFAULT nextval('public.dysu_register_id_seq'::regclass);


--
-- Name: dysu_register_aud id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_register_aud ALTER COLUMN id SET DEFAULT nextval('public.dysu_register_aud_id_seq'::regclass);


--
-- Name: dysu_answer_aud dysu_answer_aud_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_answer_aud
    ADD CONSTRAINT dysu_answer_aud_id PRIMARY KEY (id);


--
-- Name: dysu_answer dysu_answer_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_answer
    ADD CONSTRAINT dysu_answer_id PRIMARY KEY (id);


--
-- Name: dysu_field_aud dysu_field_aud_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_field_aud
    ADD CONSTRAINT dysu_field_aud_id PRIMARY KEY (id);


--
-- Name: dysu_field dysu_field_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_field
    ADD CONSTRAINT dysu_field_id PRIMARY KEY (id);


--
-- Name: dysu_form_aud dysu_form_aud_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_form_aud
    ADD CONSTRAINT dysu_form_aud_id PRIMARY KEY (id);


--
-- Name: dysu_form dysu_form_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_form
    ADD CONSTRAINT dysu_form_id PRIMARY KEY (id);


--
-- Name: dysu_form dysu_form_uq; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_form
    ADD CONSTRAINT dysu_form_uq UNIQUE (form_name);


--
-- Name: dysu_list_answers_aud dysu_list_answers_aud_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_list_answers_aud
    ADD CONSTRAINT dysu_list_answers_aud_id PRIMARY KEY (id);


--
-- Name: dysu_list_answers dysu_list_answers_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_list_answers
    ADD CONSTRAINT dysu_list_answers_id PRIMARY KEY (id);


--
-- Name: dysu_register_aud dysu_register_aud.id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_register_aud
    ADD CONSTRAINT "dysu_register_aud.id" PRIMARY KEY (id);


--
-- Name: dysu_register dysu_register_id; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_register
    ADD CONSTRAINT dysu_register_id PRIMARY KEY (id);


--
-- Name: dysu_register dysu_appointment_code; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_register
    ADD CONSTRAINT dysu_appointment_code FOREIGN KEY (appointment_code) REFERENCES public.appointment(appointment_code);


--
-- Name: dysu_list_answers dysu_field_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_list_answers
    ADD CONSTRAINT dysu_field_id FOREIGN KEY (field_id) REFERENCES public.dysu_field(id);


--
-- Name: dysu_answer dysu_field_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_answer
    ADD CONSTRAINT dysu_field_id FOREIGN KEY (field_id) REFERENCES public.dysu_field(id);


--
-- Name: dysu_field dysu_form_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_field
    ADD CONSTRAINT dysu_form_id FOREIGN KEY (form_id) REFERENCES public.dysu_form(id);


--
-- Name: dysu_register dysu_form_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_register
    ADD CONSTRAINT dysu_form_id FOREIGN KEY (form_id) REFERENCES public.dysu_form(id);


--
-- Name: dysu_form dysu_modality_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_form
    ADD CONSTRAINT dysu_modality_id FOREIGN KEY (modality_id) REFERENCES public.modality(id_modality);


--
-- Name: dysu_answer dysu_register_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_answer
    ADD CONSTRAINT dysu_register_id FOREIGN KEY (register_id) REFERENCES public.dysu_register(id);


--
-- Name: dysu_form dysu_sonata_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_form
    ADD CONSTRAINT dysu_sonata_id FOREIGN KEY (sonata_id) REFERENCES public.user_sonata(id);


--
-- Name: dysu_field dysu_sonata_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_field
    ADD CONSTRAINT dysu_sonata_id FOREIGN KEY (sonata_id) REFERENCES public.user_sonata(id);


--
-- Name: dysu_list_answers dysu_sonata_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_list_answers
    ADD CONSTRAINT dysu_sonata_id FOREIGN KEY (sonata_id) REFERENCES public.user_sonata(id);


--
-- Name: dysu_register dysu_sonata_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_register
    ADD CONSTRAINT dysu_sonata_id FOREIGN KEY (sonata_id) REFERENCES public.user_sonata(id);


--
-- Name: dysu_answer dysu_sonata_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dysu_answer
    ADD CONSTRAINT dysu_sonata_id FOREIGN KEY (sonata_id) REFERENCES public.user_sonata(id);


--
-- PostgreSQL database dump complete
--

