Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table Groups
  2. (
  3.     id             int     not null unique,
  4.     name           char(5) not null,
  5.     admission_year int     not null,
  6.     specialty      char(8) not null,
  7.     primary key (id)
  8. );
  9. create table Persons
  10. (
  11.     id         int          not null unique,
  12.     first_name varchar(30)  not null,
  13.     last_name  varchar(30)  null,
  14.     patronymic varchar(30)  null,
  15.     mail       varchar(320) null,
  16.     primary key (id)
  17. );
  18. create table Students
  19. (
  20.     grants    int not null,
  21.     group_id  int not null,
  22.     person_id int not null unique,
  23.     primary key (person_id),
  24.     foreign key (person_id) references Persons (id),
  25.     foreign key (group_id) references Groups (id)
  26. );
  27. create table Subjects
  28. (
  29.     id          int         not null unique,
  30.     name        varchar(30) not null,
  31.     is_required boolean     not null,
  32.     primary key (id)
  33. );
  34. create table Professors
  35. (
  36.     degree    varchar(30) not null,
  37.     position  varchar(30) not null,
  38.     salary    int         not null,
  39.     person_id int         not null unique,
  40.     primary key (person_id),
  41.     foreign key (person_id) references Persons (id)
  42. );
  43. create table Studying
  44. (
  45.     year       int not null,
  46.     semester   int not null,
  47.     subject_id int not null,
  48.     student_id int not null,
  49.     primary key (subject_id, student_id),
  50.     unique (subject_id, student_id),
  51.     foreign key (subject_id) references Subjects (id),
  52.     foreign key (student_id) references Students (person_id)
  53. );
  54. create table Grades
  55. (
  56.     value        char not null,
  57.     subject_id   int  not null,
  58.     student_id   int  not null,
  59.     professor_id int  not null,
  60.     primary key (subject_id, student_id),
  61.     foreign key (subject_id) references Subjects (id),
  62.     foreign key (student_id) references Students (person_id),
  63.     foreign key (professor_id) references Professors (person_id),
  64.     unique (subject_id, student_id, professor_id)
  65. );
  66. create table Teaching
  67. (
  68.     year         int not null,
  69.     semester     int not null,
  70.     subject_id   int not null,
  71.     professor_id int not null,
  72.     primary key (subject_id, professor_id),
  73.     unique (subject_id, professor_id),
  74.     foreign key (subject_id) references Subjects (id),
  75.     foreign key (professor_id) references Professors (person_id)
  76. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement