From 513f35ad8346d28f3a452ae5980cf11e5417c147 Mon Sep 17 00:00:00 2001 From: BimBom Date: Thu, 17 Sep 2026 04:32:15 +0000 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab_-1.txt | 30 +++++++++++++++++++++ lab_0.txt | 40 ++++++++++++++++++++++++++++ lab_1.txt | 63 ++++++++++++++++++++++++++++++++++++++++++++ lab_2.txt | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ schema.sql.sql | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 275 insertions(+) create mode 100644 lab_-1.txt create mode 100644 lab_0.txt create mode 100644 lab_1.txt create mode 100644 lab_2.txt create mode 100644 schema.sql.sql diff --git a/lab_-1.txt b/lab_-1.txt new file mode 100644 index 0000000..a20ca9d --- /dev/null +++ b/lab_-1.txt @@ -0,0 +1,30 @@ +Сущность: card +- card_name : TEXT +- card_stage : TEXT +- card_hp : INT +- card_number_in_pokedex : INT +- card_type : TEXT +- card_height_m : NUMERIC +- card_weight_kg : NUMERIC +- card_retreat_cost : INT +- card_year_release : INT +- card_number_in_set : TEXT + +Сущность: card_set +- set_code : TEXT +- set_name : TEXT +- set_total_card : TEXT +- set_release_date : DATE + +Сущность: attack +- attack_name : TEXT +- attack_base_damage : TEXT +- attack_effect : TEXT + +Сущность: element_type +- element_type_name : TEXT + + +Сущность: illustrator +- illustrator_name : TEXT + diff --git a/lab_0.txt b/lab_0.txt new file mode 100644 index 0000000..d340ef7 --- /dev/null +++ b/lab_0.txt @@ -0,0 +1,40 @@ +Сущность: card +- card_id : INT [PRIMARY KEY, NOT NULL] +- card_name : TEXT [NOT NULL] +- card_stage : TEXT [NOT NULL] +- card_hp : INT [NOT NULL, CHECK `card_hp > 0`] +- card_number_in_pokedex : INT +- card_type : TEXT +- card_height_m : NUMERIC [NOT NULL, CHECK `card_height_m > 0`] +- card_weight_kg : NUMERIC [NOT NULL, CHECK `card_weight_kg > 0`] +- card_retreat_cost : INT [NOT NULL] +- card_year_release : INT [NOT NULL] +- card_number_in_set : TEXT [NOT NULL] +- set_id : INT [NOT NULL, FK -> card_set.set_id] +- illustrator_id : INT [NOT NULL, FK -> illustrator.illustrator_id] +- element_type_id : INT [NOT NULL, FK -> element_type.element_type_id] + +Сущность: card_set +- set_id : INT [PRIMARY KEY, NOT NULL] +- set_code : TEXT [UNIQUE, NOT NULL] +- set_name : TEXT [NOT NULL] +- set_total_card : TEXT +- set_release_date : DATE [NOT NULL] + +Сущность: attack +- attack_id : INT [PRIMARY KEY, NOT NULL] +- attack_name : TEXT [NOT NULL] +- attack_base_damage : INT +- attack_damage_modifier : TEXT +- attack_effect : TEXT +- card_id : INT [NOT NULL, FK -> card.card_id] + +Сущность: element_type +- element_type_id : INT [PRIMARY KEY, NOT NULL] +- element_type_name : TEXT [UNIQUE, NOT NULL] + + +Сущность: illustrator +- illustrator_id : INT [PRIMARY KEY, NOT NULL] +- illustrator_name : TEXT [UNIQUE, NOT NULL] + diff --git a/lab_1.txt b/lab_1.txt new file mode 100644 index 0000000..9c9bdf9 --- /dev/null +++ b/lab_1.txt @@ -0,0 +1,63 @@ +Table card { + card_id int [primary key, not null] + card_name text [not null] + card_stage text [not null] + card_hp int [not null, check: `card_hp > 0`] + card_number_in_pokedex int + card_type text + card_height_m numeric [not null, check: `card_height_m > 0`] + card_weight_kg numeric [not null, check: `card_weight_kg > 0`] + card_retreat_cost int [not null] + card_year_release int [not null] + card_number_in_set text [not null] + set_id int [not null] + illustrator_id int [not null] + element_type_id int [not null] +} + +Table card_set { + set_id int [primary key, not null] + set_code text [unique, not null] + set_name text [not null] + set_total_card text + set_release_date date [not null] +} + +Table attack { + attack_id int [primary key, not null] + attack_name text [not null] + attack_base_damage int + attack_damage_modifier text + attack_effect text +} + +Table element_type { + element_type_id int [primary key, not null] + element_type_name text [unique, not null] +} + +Table illustrator { + illustrator_id int [primary key, not null] + illustrator_name text [unique, not null] +} + +Table card_attack { + card_attack_id int [primary key, not null] + card_id int [not null] + attack_id int [not null] +} + +Table attack_energy_cost { + attack_energy_cost_id int [primary key, not null] + attack_id int [not null] + element_type_id int [not null] + energy_quantity int [not null, check: `energy_quantity > 0`] +} + +Ref card_set: card.set_id > card_set.set_id +Ref card_illustrator: card.illustrator_id > illustrator.illustrator_id +Ref card_element_type: card.element_type_id > element_type.element_type_id +Ref attack_energy: attack_energy_cost.attack_id > attack.attack_id +Ref attack_energy_element_type: attack_energy_cost.element_type_id > element_type.element_type_id +Ref card_attack_card: card_attack.card_id > card.card_id +Ref card_attack_attack: card_attack.attack_id > attack.attack_id \ No newline at end of file diff --git a/lab_2.txt b/lab_2.txt new file mode 100644 index 0000000..e405a1e --- /dev/null +++ b/lab_2.txt @@ -0,0 +1,71 @@ +CREATE TABLE illustrator ( + illustrator_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + illustrator_name TEXT NOT NULL UNIQUE +); + +CREATE TABLE element_type ( + element_type_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + element_type_name TEXT NOT NULL UNIQUE +); + +CREATE TABLE card_set ( + set_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + set_code TEXT NOT NULL UNIQUE, + set_name TEXT NOT NULL, + set_total_card TEXT, + set_release_date DATE NOT NULL +); + +CREATE TABLE card ( + card_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + card_name TEXT NOT NULL, + card_type TEXT NOT NULL CHECK (card_type IN ('pokemon', 'energy', 'trainer')), + card_year_release INT NOT NULL, + card_number_in_set TEXT NOT NULL, + set_id INT NOT NULL REFERENCES card_set(set_id), + illustrator_id INT NOT NULL REFERENCES illustrator(illustrator_id) +); + +CREATE TABLE card_pokemon ( + card_id INT PRIMARY KEY REFERENCES card(card_id), + pokemon_stage TEXT NOT NULL, + pokemon_hp INT NOT NULL CHECK (pokemon_hp > 0), + pokemon_number_in_pokedex INT, + pokemon_height_m NUMERIC(5, 2) NOT NULL CHECK (pokemon_height_m > 0), + pokemon_weight_kg NUMERIC(5, 2) NOT NULL CHECK (pokemon_weight_kg > 0), + pokemon_retreat_cost INT NOT NULL, + element_type_id INT NOT NULL REFERENCES element_type(element_type_id) +); + +CREATE TABLE card_energy ( + card_id INT PRIMARY KEY REFERENCES card(card_id), + element_type_id INT NOT NULL REFERENCES element_type(element_type_id), + energy_is_special BOOLEAN NOT NULL +); + +CREATE TABLE card_trainer ( + card_id INT PRIMARY KEY REFERENCES card(card_id), + trainer_subtype TEXT NOT NULL CHECK (trainer_subtype IN ('Item', 'Supporter', 'Stadium')), + trainer_effect TEXT NOT NULL +); + +CREATE TABLE attack ( + attack_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + attack_name TEXT NOT NULL, + attack_base_damage INT, + attack_damage_modifier TEXT, + attack_effect TEXT +); + +CREATE TABLE card_attack ( + card_attack_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + card_id INT NOT NULL REFERENCES card_pokemon(card_id), + attack_id INT NOT NULL REFERENCES attack(attack_id) +); + +CREATE TABLE attack_energy_cost ( + attack_energy_cost_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + attack_id INT NOT NULL REFERENCES attack(attack_id), + element_type_id INT NOT NULL REFERENCES element_type(element_type_id), + energy_quantity INT NOT NULL CHECK (energy_quantity > 0) +); \ No newline at end of file diff --git a/schema.sql.sql b/schema.sql.sql new file mode 100644 index 0000000..a54e9aa --- /dev/null +++ b/schema.sql.sql @@ -0,0 +1,71 @@ +CREATE TABLE illustrator ( + illustrator_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + illustrator_name TEXT NOT NULL UNIQUE +); + +CREATE TABLE element_type ( + element_type_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + element_type_name TEXT NOT NULL UNIQUE +); + +CREATE TABLE card_set ( + set_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + set_code TEXT NOT NULL UNIQUE, + set_name TEXT NOT NULL, + set_total_card TEXT, + set_release_date DATE NOT NULL +); + +CREATE TABLE card ( + card_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + card_name TEXT NOT NULL, + card_type TEXT NOT NULL CHECK (card_type IN ('pokemon', 'energy', 'trainer')), + card_year_release INT NOT NULL, + card_number_in_set TEXT NOT NULL, + set_id INT NOT NULL REFERENCES card_set(set_id), + illustrator_id INT NOT NULL REFERENCES illustrator(illustrator_id) +); + +CREATE TABLE card_pokemon ( + card_id INT PRIMARY KEY REFERENCES card(card_id), + pokemon_stage TEXT NOT NULL, + pokemon_hp INT NOT NULL CHECK (pokemon_hp > 0), + pokemon_number_in_pokedex INT, + pokemon_height_m NUMERIC(5, 2) NOT NULL CHECK (pokemon_height_m > 0), + pokemon_weight_kg NUMERIC(5, 2) NOT NULL CHECK (pokemon_weight_kg > 0), + pokemon_retreat_cost INT NOT NULL, + element_type_id INT NOT NULL REFERENCES element_type(element_type_id) +); + +CREATE TABLE card_energy ( + card_id INT PRIMARY KEY REFERENCES card(card_id), + element_type_id INT NOT NULL REFERENCES element_type(element_type_id), + energy_is_special BOOLEAN NOT NULL +); + +CREATE TABLE card_trainer ( + card_id INT PRIMARY KEY REFERENCES card(card_id), + trainer_subtype TEXT NOT NULL CHECK (trainer_subtype IN ('Item', 'Supporter', 'Stadium')), + trainer_effect TEXT NOT NULL +); + +CREATE TABLE attack ( + attack_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + attack_name TEXT NOT NULL, + attack_base_damage INT, + attack_damage_modifier TEXT, + attack_effect TEXT +); + +CREATE TABLE card_attack ( + card_attack_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + card_id INT NOT NULL REFERENCES card_pokemon(card_id), + attack_id INT NOT NULL REFERENCES attack(attack_id) +); + +CREATE TABLE attack_energy_cost ( + attack_energy_cost_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + attack_id INT NOT NULL REFERENCES attack(attack_id), + element_type_id INT NOT NULL REFERENCES element_type(element_type_id), + energy_quantity INT NOT NULL CHECK (energy_quantity > 0) +); \ No newline at end of file