Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table Students(
- id int identity(0,1),
- namestud varchar(20) not null,
- surnamestud varchar(20) NOT NULL,
- studid int not null,
- telegramid int not null,
- course varchar(20) not null
- )
- alter table Students add constraint pk_stud primary key(id, course)
- create table Courses(
- course_c varchar(20) not null,
- pass int not null
- constraint pk_courses primary key(course_c)
- )
- create table Teachers(
- telegramid_t int not null,
- course_t varchar(20) not null
- constraint pk_teachers primary key(course_t)
- constraint fk_teachers foreign key(course_t) references Courses(course_c)
- )
- create table Grades(
- id_g int not null,
- course_g varchar(20) not null,
- grade int not null,
- attendance bit not null,
- constraint fk_grades_students foreign key(id_g,course_g) references Students(id,course) on update cascade on delete cascade,
- constraint fk_grades_teachers foreign key(course_g) references Teachers(course_t)
- )
- insert into Courses (course_c, pass) values
- ('Матстат', 170526),
- ('Питон', 480248),
- ('Матанализ', 109583),
- ('БД', 150235)
- drop table Grades;
- drop table Students;
- drop table Teachers;
- drop table Courses;
- select * from Students
- select * from Teachers
- select * from Grades
- select * from Courses
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement