File size: 1,351 Bytes
562924d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- Schema: bird__computer_student
CREATE SCHEMA IF NOT EXISTS "bird__computer_student";

-- Table: advisedBy
CREATE TABLE "bird__computer_student"."advisedBy" (
    "p_id" BIGINT NOT NULL,
    "p_id_dummy" BIGINT NOT NULL,
    CONSTRAINT "advisedBy_pk" PRIMARY KEY ("p_id", "p_id_dummy")
);

-- Table: course
CREATE TABLE "bird__computer_student"."course" (
    "course_id" BIGINT NOT NULL,
    "courseLevel" TEXT,
    CONSTRAINT "course_pk" PRIMARY KEY ("course_id")
);

-- Table: person
CREATE TABLE "bird__computer_student"."person" (
    "p_id" BIGINT NOT NULL,
    "professor" BIGINT,
    "student" BIGINT,
    "hasPosition" TEXT,
    "inPhase" TEXT,
    "yearsInProgram" TEXT,
    CONSTRAINT "person_pk" PRIMARY KEY ("p_id")
);

-- Table: taughtBy
CREATE TABLE "bird__computer_student"."taughtBy" (
    "course_id" BIGINT NOT NULL,
    "p_id" BIGINT NOT NULL,
    CONSTRAINT "taughtBy_pkey" PRIMARY KEY ("course_id", "p_id")
);

-- Foreign Keys
ALTER TABLE "bird__computer_student"."taughtBy" ADD CONSTRAINT "fk_taughtBy_0" FOREIGN KEY ("course_id") REFERENCES "bird__computer_student"."course" ("course_id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "bird__computer_student"."taughtBy" ADD CONSTRAINT "fk_taughtBy_1" FOREIGN KEY ("p_id") REFERENCES "bird__computer_student"."person" ("p_id") ON DELETE NO ACTION ON UPDATE NO ACTION;