Skip to content

Commit 346b55a

Browse files
committed
save changes
1 parent 034c32d commit 346b55a

File tree

723 files changed

+2824
-3127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

723 files changed

+2824
-3127
lines changed

databases/sem2/lab3/.~lock.1.odt#

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
,nf,laptop,07.05.2025 15:26,file:///home/nf/.var/app/org.libreoffice.LibreOffice/config/libreoffice/4;
1+
,nf,laptop,21.05.2025 17:46,file:///home/nf/.var/app/org.libreoffice.LibreOffice/config/libreoffice/4;

databases/sem2/lab3/1.odt

80.7 KB
Binary file not shown.

databases/sem2/lab3/1.pdf

231 KB
Binary file not shown.

databases/sem2/lab3/script.sql

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
-- lab 1
2+
3+
BEGIN;
4+
5+
DROP TABLE IF EXISTS Event ;
6+
DROP TABLE IF EXISTS Object ;
7+
DROP TABLE IF EXISTS AvilableAction ;
8+
9+
-- Создание таблиц
10+
CREATE TABLE Object
11+
(
12+
ObjectName TEXT PRIMARY KEY,
13+
IsGroup BOOLEAN NOT NULL DEFAULT FALSE
14+
);
15+
16+
CREATE TABLE AvilableAction
17+
(
18+
ActionName TEXT PRIMARY KEY
19+
);
20+
21+
CREATE TABLE Event
22+
(
23+
EventId SERIAL PRIMARY KEY,
24+
Action TEXT NOT NULL REFERENCES AvilableAction(ActionName),
25+
PreviousEvent INTEGER REFERENCES Event(EventId),
26+
27+
Target TEXT REFERENCES Object(ObjectName),
28+
Initiator TEXT REFERENCES Object(ObjectName),
29+
30+
CONSTRAINT EeitherTargetOrInitiator CHECK (Target IS NOT NULL OR Initiator IS NOT NULL)
31+
);
32+
33+
-- Вставка объектов
34+
INSERT INTO Object(ObjectName, IsGroup)
35+
VALUES
36+
('Глупые питекантропы', TRUE),
37+
('Способные питекантропы', TRUE),
38+
('Мысли', FALSE),
39+
('Смотрящий на Луну', FALSE),
40+
('Кристалл', FALSE),
41+
('Видения', FALSE),
42+
('Щупальца', FALSE);
43+
44+
-- Вставка действий
45+
INSERT INTO AvilableAction(ActionName)
46+
VALUES
47+
('Оставить в покое'),
48+
('Сосредоточить внимание'),
49+
('Почувствовать'),
50+
('Шариться в закаулках мозга'),
51+
('Начаться');
52+
53+
-- Вставка событий
54+
INSERT INTO Event(Action, Target, Initiator, PreviousEvent)
55+
VALUES
56+
('Оставить в покое', 'Глупые питекантропы', 'Кристалл', NULL),
57+
('Сосредоточить внимание', 'Способные питекантропы', 'Кристалл', 1),
58+
('Почувствовать', 'Смотрящий на Луну', NULL, NULL),
59+
('Шариться в закаулках мозга', 'Смотрящий на Луну', 'Щупальца', 3),
60+
('Начаться', 'Смотрящий на Луну', NULL, 4);
61+
62+
END;
63+
64+
-- lab 3
65+
66+
BEGIN;
67+
68+
ALTER TABLE Event ADD PreviousAction TEXT REFERENCES AvilableAction(ActionName);
69+
70+
/*
71+
CREATE OR REPLACE FUNCTION set_previous_action()
72+
RETURNS TRIGGER AS $$
73+
BEGIN
74+
IF NEW.PreviousEvent IS NOT NULL THEN
75+
SELECT Action INTO NEW.PreviousAction
76+
FROM Event
77+
WHERE EventId = NEW.PreviousEvent;
78+
ELSE
79+
NEW.PreviousAction := NULL;
80+
END IF;
81+
82+
RETURN NEW;
83+
END;
84+
$$ LANGUAGE plpgsql;
85+
86+
CREATE TRIGGER trigger_set_previous_action
87+
BEFORE INSERT OR UPDATE OF PreviousEvent
88+
ON Event
89+
FOR EACH ROW
90+
EXECUTE FUNCTION set_previous_action();
91+
*/
92+
93+
CREATE OR REPLACE FUNCTION cascade_action_name_update()
94+
RETURNS TRIGGER AS $$
95+
BEGIN
96+
UPDATE Event
97+
SET PreviousAction = NEW.Action
98+
WHERE PreviousEvent = NEW.EventId;
99+
100+
RETURN NULL;
101+
END;
102+
$$ LANGUAGE plpgsql;
103+
104+
CREATE TRIGGER trigger_cascade_action_name_update
105+
AFTER UPDATE OF Action
106+
ON Event
107+
FOR EACH ROW
108+
EXECUTE FUNCTION cascade_action_name_update();
109+
110+
END;
111+
112+
-- tests
113+
BEGIN;
114+
115+
INSERT INTO AvilableAction(ActionName)
116+
VALUES
117+
('Какое-то действие');
118+
119+
INSERT INTO Event(Action, Target, Initiator, PreviousEvent)
120+
VALUES
121+
('Какое-то действие', 'Смотрящий на Луну', NULL, 4);
122+
123+
UPDATE Event
124+
SET Action = 'Какое-то действие'
125+
WHERE Event.EventId = 1;
126+
127+
END;

programming/sem2/lab5_v2/docs/client/Main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<html lang="ru">
33
<head>
4-
<!-- Generated by javadoc (22) on Sun May 18 13:38:31 MSK 2025 -->
4+
<!-- Generated by javadoc (22) on Sun May 18 15:46:57 MSK 2025 -->
55
<title>Main</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

programming/sem2/lab5_v2/docs/client/allclasses-index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<html lang="ru">
33
<head>
4-
<!-- Generated by javadoc (22) on Sun May 18 13:38:31 MSK 2025 -->
4+
<!-- Generated by javadoc (22) on Sun May 18 15:46:57 MSK 2025 -->
55
<title>All Classes and Interfaces</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

programming/sem2/lab5_v2/docs/client/allpackages-index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<html lang="ru">
33
<head>
4-
<!-- Generated by javadoc (22) on Sun May 18 13:38:31 MSK 2025 -->
4+
<!-- Generated by javadoc (22) on Sun May 18 15:46:57 MSK 2025 -->
55
<title>All Packages</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

programming/sem2/lab5_v2/docs/client/client/Main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<html lang="ru">
33
<head>
4-
<!-- Generated by javadoc (22) on Sun May 18 13:38:31 MSK 2025 -->
4+
<!-- Generated by javadoc (22) on Sun May 18 15:46:57 MSK 2025 -->
55
<title>Main</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

programming/sem2/lab5_v2/docs/client/client/commands/BasicCommand.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<html lang="ru">
33
<head>
4-
<!-- Generated by javadoc (22) on Sun May 18 13:38:31 MSK 2025 -->
4+
<!-- Generated by javadoc (22) on Sun May 18 15:46:57 MSK 2025 -->
55
<title>BasicCommand</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

programming/sem2/lab5_v2/docs/client/client/commands/exceptions/ElementNotFound.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<html lang="ru">
33
<head>
4-
<!-- Generated by javadoc (22) on Sun May 18 13:38:31 MSK 2025 -->
4+
<!-- Generated by javadoc (22) on Sun May 18 15:46:57 MSK 2025 -->
55
<title>ElementNotFound</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

0 commit comments

Comments
 (0)