drop table if exists Ий_Тапсырмасы; drop table if exists Бағалау; drop table if exists Сабақтар_Кестесі; drop table if exists Сабақтар; drop table if exists Мұғалімдер; drop table if exists Оқушылар; drop table if exists Топтар; drop table if exists Пользователи;
create table Пользователи ( user_id int not null primary key, username varchar(30), password varchar(30), role varchar(30) );
create table Топтар ( group_id int not null primary key, group_name varchar(30), teacher_id int );
drop table if exists Ий_Тапсырмасы;
drop table if exists Бағалау;
drop table if exists Сабақтар_Кестесі;
drop table if exists Сабақтар;
drop table if exists Мұғалімдер;
drop table if exists Оқушылар;
drop table if exists Топтар;
drop table if exists Пользователи;
create table Пользователи (
user_id int not null primary key,
username varchar(30),
password varchar(30),
role varchar(30)
);
create table Топтар (
group_id int not null primary key,
group_name varchar(30),
teacher_id int
);
create table Оқушылар (
student_id int not null primary key,
user_id int,
first_name varchar(30),
last_name varchar(30),
group_id int,
foreign key (user_id) references Пользователи(user_id),
foreign key (group_id) references Топтар(group_id)
);
create table Мұғалімдер (
teacher_id int not null primary key,
user_id int,
first_name varchar(30),
last_name varchar(30),
subjects varchar(30),
foreign key (user_id) references Пользователи(user_id)
);
create table Сабақтар (
subject_id int not null primary key,
subject_name varchar(30),
group_name varchar(30)
);
create table Сабақтар_Кестесі (
schedule_id int not null primary key,
subject_id int,
teacher_id int,
week_day varchar(30),
first_time int,
last_time int,
foreign key (subject_id) references Сабақтар(subject_id),
foreign key (teacher_id) references Мұғалімдер(teacher_id)
);
create table Бағалау (
grade_id int not null primary key,
student_id int,
subject_id int,
grade int,
day int,
foreign key (student_id) references Оқушылар(student_id),
foreign key (subject_id) references Сабақтар(subject_id)
);