USE user312_db;
GO
/* =========================================
1. ПОСЕЩАЕМОСТЬ ЗА МАРТ
========================================= */
CREATE TABLE posesh_mart13
(
Kod_studenta INT NOT NULL,
Uvazh_prop INT NOT NULL DEFAULT 0,
Neuvazh_prop INT NOT NULL DEFAULT 0,
CONSTRAINT PK_posesh_mart13
PRIMARY KEY (Kod_studenta),
CONSTRAINT FK_posesh_mart13_student13
FOREIGN KEY (Kod_studenta)
REFERENCES student13(Kod_studenta)
);
/* Добавляем всех студентов */
INSERT INTO posesh_mart13
(
Kod_studenta,
Uvazh_prop,
Neuvazh_prop
)
SELECT
Kod_studenta,
0,
0
FROM student13;
/* =========================================
2. ПОСЕЩАЕМОСТЬ ЗА АПРЕЛЬ
========================================= */
CREATE TABLE posesh_aprel13
(
Kod_studenta INT NOT NULL,
Uvazh_prop INT NOT NULL DEFAULT 0,
Neuvazh_prop INT NOT NULL DEFAULT 0,
CONSTRAINT PK_posesh_aprel13
PRIMARY KEY (Kod_studenta),
CONSTRAINT FK_posesh_aprel13_student13
FOREIGN KEY (Kod_studenta)
REFERENCES student13(Kod_studenta)
);
INSERT INTO posesh_aprel13
(
Kod_studenta,
Uvazh_prop,
Neuvazh_prop
)
SELECT
Kod_studenta,
0,
0
FROM student13;
/* =========================================
3. ПОСЕЩАЕМОСТЬ ЗА МАЙ
========================================= */
CREATE TABLE posesh_may13
(
Kod_studenta INT NOT NULL,
Uvazh_prop INT NOT NULL DEFAULT 0,
Neuvazh_prop INT NOT NULL DEFAULT 0,
CONSTRAINT PK_posesh_may13
PRIMARY KEY (Kod_studenta),
CONSTRAINT FK_posesh_may13_student13
FOREIGN KEY (Kod_studenta)
REFERENCES student13(Kod_studenta)
);
INSERT INTO posesh_may13
(
Kod_studenta,
Uvazh_prop,
Neuvazh_prop
)
SELECT
Kod_studenta,
0,
0
FROM student13;