SHARE
TWEET

Untitled

a guest Dec 11th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table Students(
  2. id int identity(0,1),
  3. namestud varchar(20) not null,
  4. surnamestud varchar(20) NOT NULL,
  5. studid int not null,
  6. telegramid int not null,
  7. course varchar(20) not null
  8. )
  9.  
  10. alter table Students add constraint pk_stud primary key(id, course)
  11.  
  12.  
  13.  
  14. create table Courses(
  15. course_c varchar(20) not null,
  16. pass int not null
  17. constraint pk_courses primary key(course_c)
  18. )
  19.  
  20.  
  21. create table Teachers(
  22. telegramid_t int not null,
  23. course_t varchar(20) not null
  24. constraint pk_teachers primary key(course_t)
  25. constraint fk_teachers foreign key(course_t) references Courses(course_c)
  26. )
  27.  
  28. create table Grades(
  29. id_g int not null,
  30. course_g varchar(20) not null,
  31. grade int not null,
  32. attendance bit not null,
  33. constraint fk_grades_students foreign key(id_g,course_g) references Students(id,course) on update cascade on delete cascade,
  34. constraint fk_grades_teachers foreign key(course_g) references Teachers(course_t)
  35. )
  36.  
  37.  
  38. insert into Courses  (course_c, pass) values
  39. ('Матстат', 170526),
  40. ('Питон', 480248),
  41. ('Матанализ', 109583),
  42. ('БД', 150235)
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. drop table Grades;
  52. drop table Students;
  53. drop table Teachers;
  54. drop table Courses;
  55.  
  56.  
  57. select * from Students
  58. select * from Teachers
  59. select * from Grades
  60. select * from Courses
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top