testsys_db.sql

text/plain

Filename: testsys_db.sql
Type: text/plain
Part: 0
Message: PostgreSQL program question.
CREATE TABLE Subject (
   Id int4 NOT NULL UNIQUE,
   Description text);

CREATE TABLE Test (
   Id int4 NOT NULL UNIQUE,
   Id_Subject int4 NOT NULL,
   TestNum int2,
   Description text);

CREATE INDEX Test_Id_Subject ON Test (
   Id_Subject);

CREATE TABLE Question (
   Id int4 NOT NULL UNIQUE,
   Id_Test int4 NOT NULL,
   Question_Text text,
   Question text,
   Bonus int2);

CREATE INDEX Test_Id_Test ON Question (
   Id_Test);

CREATE TABLE Answer (
   Id int4 NOT NULL UNIQUE,
   Id_Question int4 NOT NULL,
   Answer_Text text,
   Answer boolean);

CREATE INDEX Test_Id_Question ON Answer (
   Id_Question);

CREATE TABLE Teacher (
   Id int4 NOT NULL UNIQUE,
   Linux_Name text,
   Description text);

CREATE TABLE Groups (
   Id int4 NOT NULL UNIQUE,
   Description text);

CREATE TABLE Student (
   Id int4 NOT NULL UNIQUE,
   Id_Group int4 NOT NULL,
   Name text);

CREATE INDEX Student_Id_Group ON Student (
   Id_Group);

CREATE TABLE Test_Result (
   Id_Test int4 NOT NULL,
   Id_Student int4 NOT NULL,
   Result int2);

CREATE TABLE Teacher_To_Subject (
   Id_Teacher int4 NOT NULL,
   Id_Subject int4 NOT NULL);

CREATE TABLE Teacher_To_Group (
   Id_Group int4 NOT NULL,
   Id_Teacher int4 NOT NULL);

CREATE TABLE Run_Test (
   Id_Student int4 NOT NULL,
   Id_Test int4 NOT NULL,
   StartTime time NOT NULL,
   StopTime time NOT NULL);