Базы данных
Введение
ФИО,Предмет,Оценка Белоус Д.П.,ВведПрог,5 Белоус Д.П.,Парадигмы,5 Дмитриев В.Д.,ВведПрог,3 Дмитриев В.Д.,Парадигмы,4
ФИО Предмет Оценка String, 14 String, 12 Number, 1 Белоус Д.П. ВведПрог 5 Белоус Д.П. Парадигмы 5 Дмитриев В.Д. ВведПрог 3 Дмитриев В.Д. Парадигмы 4
create database CTD;
use CTD;
create table Groups ( group_id int, group_no char(6) ); create table Students ( student_id int, name varchar(50), group_id int );
insert into Groups (group_id, group_no) values (1, 'M34331'), (2, 'M34391'); insert into Students (student_id, name, group_id) values (1, 'Kirill Konovalov', 2), (2, 'Andrey Matveev', 2), (3, 'Dmitry Ivchenko', 1);
select group_id, group_no from Groups;
select student_id, name, group_id from Students;
select name, group_no from Students natural join Groups;
select Students.name, Groups.group_no from Students inner join Groups on Students.group_id = Groups.group_id;
update Students set group_id = 1 where student_id = 2;
update Students set group_id = 1 where name = 'Andrey Matveev';
insert into Groups (group_id, group_no) values (1, 'M34311');
delete from Groups where group_no = 'M34311';
alter table Groups add constraint group_id_unique unique (group_id);
update Students set group_id = 5 where student_id = 2;
update Students set group_id = 1 where student_id = 2;
alter table Students add foreign key (group_id) references Groups (group_id);