Compare commits

...

6 Commits

Author SHA1 Message Date
nikbel2004@outlook.com
910043144d Laboratory_5-6 2024-09-16 00:15:26 +04:00
nikbel2004@outlook.com
973ee54756 Laboratory_5-6 2024-09-15 23:52:04 +04:00
nikbel2004@outlook.com
84fcba6200 Laboratory_4 2024-09-15 23:47:51 +04:00
nikbel2004@outlook.com
851d8c0c6d Laboratory_3 2024-09-15 23:47:08 +04:00
nikbel2004@outlook.com
7849dd4531 Laboratory_2 2024-09-15 23:46:31 +04:00
nikbel2004@outlook.com
a0a3fd0be4 Laboratory_1 2024-09-15 23:43:56 +04:00
6 changed files with 183 additions and 0 deletions

33
Lab 5-6/book.xml Normal file
View File

@ -0,0 +1,33 @@
<?xml-stylesheet type="text/xml" href="library.xsl" version="2.0"?>
<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<bookid>1</bookid>
<genreid>1</genreid>
<title>Преступление и наказание</title>
<author>Ф.М.Достоевский</author>
</row>
<row>
<bookid>2</bookid>
<genreid>1</genreid>
<title>Мёртвые души</title>
<author>Н.В.Гоголь</author>
</row>
<row>
<bookid>3</bookid>
<genreid>2</genreid>
<title>Улитка на склоне</title>
<author>Братья Стругацкие</author>
</row>
<row>
<bookid>4</bookid>
<genreid>3</genreid>
<title>Любовь хулигана</title>
<author>С.А.Есенин</author>
</row>
</book>

23
Lab 5-6/employee.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml-stylesheet type="text/xml" href="library.xsl" version="2.0"?>
<employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<employeeid>1</employeeid>
<genreid>3</genreid>
<fio>Иванов Иван Иванович</fio>
</row>
<row>
<employeeid>2</employeeid>
<genreid>2</genreid>
<fio>Медведев Евгений Юрьевич</fio>
</row>
<row>
<employeeid>3</employeeid>
<genreid>1</genreid>
<fio>Михайлова Юлия Вадимовна</fio>
</row>
</employee>

20
Lab 5-6/genre.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml-stylesheet type="text/xml" href="library.xsl" version="2.0"?>
<genre xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<genreid>1</genreid>
<genrename>Классика</genrename>
</row>
<row>
<genreid>2</genreid>
<genrename>Научная фантастика</genrename>
</row>
<row>
<genreid>3</genreid>
<genrename>Поэзия</genrename>
</row>
</genre>

53
Lab 5-6/library.xsl Normal file
View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1 align="center">Library</h1>
<table border="3" align="center" >
<tr>
<th>ID жанра</th>
<th>Название жанра</th>
</tr>
<xsl:for-each select="genre/row">
<tr>
<td><xsl:value-of select="genreid"/></td>
<td><xsl:value-of select="genrename"/></td>
</tr>
</xsl:for-each>
</table>
<table border="3" align="center" >
<tr>
<th>ID сотрудника</th>
<th>ID жанра</th>
<th>ФИО</th>
</tr>
<xsl:for-each select="employee/row">
<tr>
<td><xsl:value-of select="employeeid"/></td>
<td><xsl:value-of select="genreid"/></td>
<td><xsl:value-of select="fio"/></td>
</tr>
</xsl:for-each>
</table>
<table border="3" align="center" >
<tr>
<th>ID книги</th>
<th>ID жанра</th>
<th>Название</th>
<th>Автор</th>
</tr>
<xsl:for-each select="book/row">
<tr>
<td><xsl:value-of select="bookid"/></td>
<td><xsl:value-of select="genreid"/></td>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

54
Lab 5-6/script.txt Normal file
View File

@ -0,0 +1,54 @@
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)

BIN
Сценарии.docx Normal file

Binary file not shown.