-- Your SQL goes here

--
-- PostgreSQL database dump
--

-- Dumped from database version 13.3
-- Dumped by pg_dump version 13.3


CREATE TABLE lianxi
(
    id                    character varying NOT NULL,
    video_url             character varying,
    video_id              character varying,
    create_at             timestamp without time zone,
    jihua_qumu_section_id character varying NOT NULL,
    audio_question_url    character varying,
    audio_question_id     character varying,
    text_question         text
);


CREATE TABLE jihua
(
    id         character varying           NOT NULL,
    start_date timestamp without time zone NOT NULL,
    end_date   timestamp without time zone NOT NULL,
    student_id character varying           NOT NULL,
    teacher_id character varying           NOT NULL,
    beizhu     character varying
);


CREATE TABLE jihua_qumu_section
(
    id              character varying NOT NULL,
    jihua_id        character varying NOT NULL,
    qumu_section_id character varying NOT NULL,
    meta            jsonb
);


CREATE TABLE piyue
(
    id         character varying NOT NULL,
    lianxi_id  character varying NOT NULL,
    content    jsonb             NOT NULL,
    teacher_id character varying NOT NULL,
    rating     jsonb
);


CREATE TABLE piyue_info
(
    id               character varying NOT NULL,
    piyue_id         character varying NOT NULL,
    lianxi_video_pos jsonb,
    qupu_pos         jsonb,
    comment          text
);


CREATE TABLE qumu
(
    name      character varying NOT NULL,
    id        character varying NOT NULL,
    qumu_type integer           NOT NULL
);


CREATE TABLE qumu_info
(
    id         character varying NOT NULL,
    meta       jsonb,
    qumu_id    character varying NOT NULL,
    created_by character varying NOT NULL
);

CREATE TABLE qumu_section
(
    id           character varying NOT NULL,
    created_by   character varying NOT NULL,
    qupu_id      character varying,
    qupu_url     character varying,
    shifan_id    character varying,
    shifan_url   character varying,
    section_name character varying NOT NULL,
    qumu_id      character varying NOT NULL,
    task         jsonb
);

CREATE TABLE teacher_student
(
    teacher_id character varying NOT NULL,
    student_id character varying NOT NULL,
    id         character varying NOT NULL
);


ALTER TABLE ONLY piyue_info
    ADD CONSTRAINT piyue_info_pk PRIMARY KEY (id);


ALTER TABLE ONLY piyue
    ADD CONSTRAINT piyue_pk PRIMARY KEY (id);


ALTER TABLE ONLY jihua_qumu_section
    ADD CONSTRAINT jihua_qumu_section_pk PRIMARY KEY (id);


ALTER TABLE ONLY qumu_info
    ADD CONSTRAINT qumu_meta_pk PRIMARY KEY (id);

ALTER TABLE ONLY qumu
    ADD CONSTRAINT qumu_pk PRIMARY KEY (id);



ALTER TABLE ONLY qumu_section
    ADD CONSTRAINT qumu_section_pk PRIMARY KEY (id);

ALTER TABLE ONLY teacher_student
    ADD CONSTRAINT teacher_student_pk PRIMARY KEY (id);


ALTER TABLE ONLY jihua
    ADD CONSTRAINT jihua_pk PRIMARY KEY (id);


ALTER TABLE ONLY lianxi
    ADD CONSTRAINT lianxi_pk PRIMARY KEY (id);


CREATE UNIQUE INDEX piyue_id_uindex ON piyue USING btree (id);


CREATE UNIQUE INDEX piyue_info_id_uindex ON piyue_info USING btree (id);


CREATE UNIQUE INDEX qumu_id_uindex ON qumu USING btree (id);



CREATE UNIQUE INDEX qumu_meta_id_uindex ON qumu_info USING btree (id);



CREATE UNIQUE INDEX qumu_name_uindex ON qumu USING btree (name);



CREATE UNIQUE INDEX jihua_id_uindex ON jihua USING btree (id);


CREATE UNIQUE INDEX lianxi_id_uindex ON lianxi USING btree (id);


ALTER TABLE ONLY lianxi
    ADD CONSTRAINT jihua_qumu_section_id_fk FOREIGN KEY (jihua_qumu_section_id) REFERENCES jihua_qumu_section (id);


ALTER TABLE ONLY piyue_info
    ADD CONSTRAINT piyue_info_piyue_id_fk FOREIGN KEY (piyue_id) REFERENCES piyue (id);


ALTER TABLE ONLY piyue
    ADD CONSTRAINT piyue_lianxi_id_fk FOREIGN KEY (lianxi_id) REFERENCES lianxi (id);


ALTER TABLE ONLY jihua_qumu_section
    ADD CONSTRAINT jihua_qumu_section_jihua_id_fk FOREIGN KEY (jihua_id) REFERENCES jihua (id);


ALTER TABLE ONLY jihua_qumu_section
    ADD CONSTRAINT jihua_qumu_section_qumu_section_id_fk FOREIGN KEY (qumu_section_id) REFERENCES qumu_section (id);


ALTER TABLE ONLY qumu_info
    ADD CONSTRAINT qumu_info_qumu_id_fk FOREIGN KEY (qumu_id) REFERENCES qumu (id);


ALTER TABLE ONLY qumu_section
    ADD CONSTRAINT qumu_section_qumu_id_fk FOREIGN KEY (qumu_id) REFERENCES qumu (id);


--
-- PostgreSQL database dump complete
--

