MiAKD/Lab 5-6/script.txt
nikbel2004@outlook.com 635dd2fd31 AllLabs
2024-09-16 00:16:06 +04:00

54 lines
1.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

CREATE TABLE Genre (
GenreID INTEGER PRIMARY KEY,
GenreName varchar(30) NOT NULL
);
CREATE TABLE Employee (
EmployeeID int PRIMARY KEY,
GenreID INTEGER,
FIO varchar(50) NOT NULL,
FOREIGN KEY (GenreID) REFERENCES Genre (GenreID)
);
CREATE TABLE Book (
BookID INTEGER PRIMARY KEY,
GenreID INTEGER,
Title varchar(200) NOT NULL,
Author varchar(200) NOT NULL,
FOREIGN KEY (GenreID) REFERENCES Genre (GenreID)
);
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';
/* === Индексы (6 lab) === */
CREATE INDEX index_g
ON Genre (GenreID)
CREATE INDEX index_e
ON Employee (EmployeeID)
CREATE INDEX index_b
ON Book (BookID)