2024-09-15 23:52:04 +04:00
|
|
|
|
CREATE TABLE Genre (
|
2024-09-16 00:16:06 +04:00
|
|
|
|
GenreID INTEGER PRIMARY KEY,
|
2024-09-15 23:52:04 +04:00
|
|
|
|
GenreName varchar(30) NOT NULL
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE Employee (
|
2024-09-16 00:16:06 +04:00
|
|
|
|
EmployeeID int PRIMARY KEY,
|
2024-09-15 23:52:04 +04:00
|
|
|
|
GenreID INTEGER,
|
|
|
|
|
FIO varchar(50) NOT NULL,
|
|
|
|
|
|
2024-09-16 00:16:06 +04:00
|
|
|
|
FOREIGN KEY (GenreID) REFERENCES Genre (GenreID)
|
2024-09-15 23:52:04 +04:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE Book (
|
2024-09-16 00:16:06 +04:00
|
|
|
|
BookID INTEGER PRIMARY KEY,
|
2024-09-15 23:52:04 +04:00
|
|
|
|
GenreID INTEGER,
|
|
|
|
|
Title varchar(200) NOT NULL,
|
|
|
|
|
Author varchar(200) NOT NULL,
|
2024-09-16 00:16:06 +04:00
|
|
|
|
|
|
|
|
|
FOREIGN KEY (GenreID) REFERENCES Genre (GenreID)
|
2024-09-15 23:52:04 +04:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
INSERT INTO Genre VALUES
|
|
|
|
|
(1, 'Классика'),
|
|
|
|
|
(2, 'Научная фантастика'),
|
|
|
|
|
(3, 'Поэзия')
|
|
|
|
|
|
|
|
|
|
INSERT INTO Employee VALUES
|
|
|
|
|
(1, 3, 'Иванов Иван Иванович'),
|
|
|
|
|
(2, 2, 'Медведев Евгений Юрьевич'),
|
|
|
|
|
(3, 1, 'Михайлова Юлия Вадимовна')
|
|
|
|
|
|
|
|
|
|
INSERT INTO Book VALUES
|
|
|
|
|
(1, 1, 'Преступление и наказание', 'Ф.М.Достоевский'),
|
|
|
|
|
(2, 1, 'Мёртвые души', 'Н.В.Гоголь'),
|
|
|
|
|
(3, 2, 'Улитка на склоне', 'Братья Стругацкие'),
|
|
|
|
|
(4, 3, 'Любовь хулигана', 'С.А.Есенин')
|
|
|
|
|
|
|
|
|
|
COPY (SELECT table_to_xml('Genre', true, false, '')) to 'E:\MiAKD\Lab 5-6\genre.xml';
|
|
|
|
|
COPY (SELECT table_to_xml('Employee', true, false, '')) to 'E:\MiAKD\Lab 5-6\employee.xml';
|
|
|
|
|
COPY (SELECT table_to_xml('Book', true, false, '')) to 'E:\MiAKD\Lab 5-6\book.xml';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-16 00:16:06 +04:00
|
|
|
|
/* === Индексы (6 lab) === */
|
2024-09-15 23:52:04 +04:00
|
|
|
|
|
|
|
|
|
CREATE INDEX index_g
|
|
|
|
|
ON Genre (GenreID)
|
|
|
|
|
|
|
|
|
|
CREATE INDEX index_e
|
|
|
|
|
ON Employee (EmployeeID)
|
|
|
|
|
|
|
|
|
|
CREATE INDEX index_b
|
|
|
|
|
ON Book (BookID)
|