From 4c2497c7a39688ce61e17b0afe62f90a076b7364 Mon Sep 17 00:00:00 2001 From: Fan Date: Tue, 29 Sep 2026 11:20:26 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- schema | 299 +++++++++++++++++++++++++-------------------------------- 1 file changed, 133 insertions(+), 166 deletions(-) diff --git a/schema b/schema index 7a7d2e1..6c35862 100644 --- a/schema +++ b/schema @@ -1,186 +1,153 @@ -Table card { - card_id int [primary key,not null] - card_name text [not null] - card_rarity text - card_number text [not null] - card_artist text - card_release_date date - card_image_url text - card_type text [not null] - indexes { - (card_set_id, card_number) [unique] -} - card_set_id int [not null, ref: > card_set.card_set_id] - illustrator_id int [not null, ref: > illustrator.illustrator_id] - card_pokemon_id int [not null, primary key, ref: - card_pokemon.card_pokemon_id] - attack_energy_cost_id int [not null, ref: > attack_energy_cost.attack_energy_cost_id] - energy_type_id int [not null, ref: > energy_type.element_type_id] - coach_id int [not null, ref: > coach.coach_id] -} +CREATE TABLE card_set ( + set_name VARCHAR(255) NOT NULL, + set_id VARCHAR(20) PRIMARY key not null, + set_series VARCHAR(20) NOT NULL, + set_total_cards INT NOT NULL, + set_release_date DATE NOT null +); -Table card_pokemon { - card_pokemon_id int [primary key, not null] - card_pokemon_hp int [not null, check: `card_hp > 0`] - card_pokemon_hieght numeric - card_pokemon_weight numeric - card_pokemon_name text [not null] - card_pokemon_pokedex_entry_id int [not null] - card_card_id int [primary key, not null] - card_pokemon_stage text [not null] - card_pokemon_evloves_from text - card_pokemon_category text [not null] - entrgy_type_id int [not null, ref: > energy_type.energy_type_id] - attack_energy_cost_id int [not null, ref: > attack_energy_cost.attack_energy_cost_id] - attack_id int [not null, ref: > attack.attack_id] - coach_id int [not null, ref: > coach.coach_id] - card_pokemon_pokedex_number int [null] - card_pokemon_retreat_cost int [not null] - card_pokemon_printed_height text [not null] - card_pokemon_printed_weight text [not null] +INSERT INTO card_set (set_name, set_id, set_series, set_total_cards, set_release_date) VALUES +('XY Базовый набор', 'XY1', 'XY', 146, '2014-02-05'), +('XY Огненная вспышка', 'XY2', 'XY', 106, '2014-05-07'), +('XY Яростный кулак', 'XY3', 'XY', 111, '2014-08-13'), +('XY Призрачные силы', 'XY4', 'XY', 119, '2014-11-05'), +('XY Первобытная дуэль', 'XY5', 'XY', 160, '2015-02-04'), +('XY Грохочущие небеса', 'XY6', 'XY', 108, '2015-05-06'), +('XY Древние истоки', 'XY7', 'XY', 98, '2015-08-12'), +('XY Прорыв', 'XY8', 'XY', 162, '2015-11-04'), +('XY Тайное превосходство', 'XY9', 'XY', 122, '2016-02-03'), +('XY Столкновение судеб', 'XY10', 'XY', 124, '2016-05-02'); -} +CREATE TABLE card ( + card_id INT PRIMARY KEY, + card_number TEXT NOT NULL, + card_set_id VARCHAR(20) NOT null, + card_name TEXT NOT NULL, + card_rarity TEXT, + card_type TEXT NOT null, + card_image_url TEXT, + UNIQUE (card_set_id, card_number) +); -Table pokemon_sub_type { - pokemon_sub_type_id int [primary key, not null, ref: - card_pokemon.card_pokemon_id] - pokemon_sub_type_name text [not null] - pokemon_sub_type_default_prize_count int [not null] - pokemon_sub_type_global_rule_text text [not null] -} +CREATE TABLE card_pokemon ( + pokemon_card_id INT PRIMARY key, + pokemon_pokedex_number INT, + pokemon_pokedex_entry_id INT, + pokemon_hp INT, + pokemon_stage TEXT, + pokemon_evolves_from TEXT, + pokemon_retreat_cost INT, + pokemon_sub_type_id INT, + pokemon_category TEXT, + pokemon_printed_height TEXT, + pokemon_printed_weight TEXT +); -Table card_set { - card_set_id int [primary key, not null] - card_set_releaced_date date - card_set_name text [not null, unique] - card_set_code int [not null, unique] - card_set_total_cards int [not null, unique] - card_set_series text [not null] - card_total_cards int [not null] - card_set_logo_url text [not null] - card_set_symbol_url text [not null] -} +CREATE TABLE pokemon_species ( + pokemon_species_pokedex_number INT PRIMARY KEY, + pokemon_species_end_name VARCHAR(150) NOT NULL, + pokemon_species_generation INT NOT NULL, + pokemon_species_height_m FLOAT NOT NULL, + pokemon_species_weight_kg FLOAT NOT NULL +); -Table attack { - attack_id int [primary key, not null] - attack_name text [not null] - attack_base_damage text [null, check: `attack_base_damege >= 0`] - attack_effect text - attack_retreat_cost int [null, check: `attack_retreat_cost >= 0`] -} +CREATE TABLE pokemon_sub_type ( + sub_type_id INT PRIMARY KEY, + sub_type_name VARCHAR(100) NOT NULL, + sub_type_default_prize_count INT NOT NULL, + sub_type_global_rule_text TEXT NOT NULL +); -Table card_attack { - card_attack_id int [primary key] - card_id int [not null, ref: > card.card_id] - attack_id int [not null, ref: > attack.attack_id] - card_attack_position int [null, check: `card_attack_position > 0`] -} +CREATE TABLE pokemon_ability ( + ability_pokemon_card_id INT PRIMARY KEY, + ability_type_id INT NOT null, + ability_name VARCHAR(150) NOT NULL, + ability_effect_text TEXT NOT NULL +); -Table energy_type { - energy_quantily text [null] - element_type_id int [primary key, not null] - element_type_name text [not null, unique] - energy_type_id int [not null, primary key] - energy_type_icon_url text [not null] -} +CREATE TABLE pokemon_attack_link ( + link_id INT PRIMARY KEY, + link_pokemon_card_id INT, + link_attack_name_id INT, + link_damage_value TEXT, + link_effect_text TEXT, + UNIQUE (link_pokemon_card_id, link_attack_name_id) +); -Table illustrator { - illustrator_name text [not null, unique] - illustrator_id int [primary key, not null] - illustrator_nationality text [null] - illustrator_natinality twxt [null] -} +CREATE TABLE pokemon_attribute ( + attribute_id INT PRIMARY KEY, + attribute_pokemon_card_id INT NOT null, + attribute_energy_type_id INT NOT NULL, + attribute_kind TEXT NOT NULL, + attribute_modifier_value TEXT NOT NULL, + UNIQUE (attribute_pokemon_card_id, attribute_energy_type_id, attribute_kind) +); -Table attack_energy_cost { - attack_energy_cost_id int [primary key] - attack_id int [not null] - element_type_id int [not null] -} -Table coach { - coach_id int [primary key, not null] - coach_name text [not null, unique] - coach_type int [not null] - coach_releaced_date date [not null] - coach_skill text [not null] - coach_description text [not null] - coach_rarity text [not null] - coach_image_url text [not null] - coach_printed_type_id int [not null] - coach_effect_text text [not null] - coach_is_ace_spec boolean [not null] -} +CREATE TABLE coach_card ( + couch_card_id INT PRIMARY key, + couch_printed_type_id INT, + couch_effect_text TEXT, + couch_is_ace_spec BOOLEAN NOT null default false +); -Table ability_type { - ability_type_id int [primary key, not null] - ability_type_name text [not null] -} +CREATE TABLE trainer_mechanic_link ( + mechanic_link_trainer_card_id INT NOT null, + mechanic_link_mechanic_id INT NOT null, + PRIMARY KEY (mechanic_link_trainer_card_id, mechanic_link_mechanic_id) +); -Table attack_name { - attack_name_id int [primary key, not null] - attack_name_title text [not null] -} +create table couch_printed_type ( + couch_type_id INT PRIMARY KEY, + couch_type_name TEXT NOT NULL UNIQUE +); -Table trainer_printed_type{ - trainer_prinded_type_id int [primary key, not null, ref: - coach.coach_id] - trainer_printed_type_name text [not null] -} +CREATE TABLE energy_type ( + energy_type_id INT primary key, + energy_type_name TEXT NOT NULL UNIQUE, + energy_type_icon_url TEXT +); -Table game_mechanic { - mechanic_id int [primary key, not null] - mechenic_name text [not null] -} +CREATE TABLE ability_type ( + ability_type_id INT PRIMARY KEY, + ability_type_name TEXT NOT NULL +); -Table pokemon_species { - pokemon_species_pokedex_number int [not null, primary key, ref: - card_pokemon.card_pokemon_id] - pokemon_species_end_name text [not null] - pokemon_species_generetion int [not null] - pokemon_species_height_m float [not null] - pokemon_species_weight_kg float [not null] -} +CREATE TABLE attack_name ( + attack_name_id INT PRIMARY KEY, + attack_name_title TEXT NOT NULL +); -Table pokedex_entry { - pokedex_entry_id int [not null, primary key, ref: - card_pokemon.card_pokemon_id] - pokedex_entry_pokedex_number int [not null] - pokedex_entry_source_game text [not null] - pokedex_entry_description text [not null] -} +CREATE TABLE game_mechanic ( + mechanic_id INT PRIMARY KEY, + mechanic_name VARCHAR(150) NOT NULL +); -Table energy_card { - energy_card_id int [not null, primary key, ref: - card.card_id] - energy_is_special boolean [not null] - energy_main_type_id int [null] - energy_effect_text text [null] -} +CREATE TABLE pokedex_entry ( + pokedex_entry_id INT PRIMARY KEY, + pokedex_entry_pokedex_number INT NOT NULL, + pokedex_entry_source_game VARCHAR(100) NOT NULL, + pokedex_entry_description TEXT NOT NULL +); -Table pokemon_ability { - ability_pokemon_card_id int [not null, primary key, ref: - card_pokemon.card_pokemon_id] - ability_type_id int [not null] - ability_name text [not null] - ability_effect_text text [not null] -} -Table pokemon_attack_link { - link_id int [not null] - link_pokemon_card_id int [not null] - link_attack_name_id int [not null] - link_damage_value text [not null] - link_effect_text text [null] - indexes { - (link_pokemon_card_id, link_attack_name_id) [unique] -} -} +CREATE TABLE attack_energy_cost ( + attack_energy_cost_id INT PRIMARY KEY, + attack_id INT NOT null, + element_type_id INT not null +); -Table pokemon_attribute { - attribute_id int [not null, ref: > card_pokemon.card_pokemon_id] - attribute_pokemon_card_id int [not null] - attribute_energy_type_id int [not null] - attribute_kind text [not null] - attribute_modifier_value text [not null] - indexes { - (attribute_pokemon_card_id, attribute_energy_type_id, attribute_kind) [unique] -} -} -Table trainer_mechanic_link { - mechanic_link_trainer_card_id int [not null, ref: > game_mechanic.mechanic_id] - mechanic_link_mechanic_id int [not null] - primery key (mechanic_link_trainer_card_id, mechanic_link_mechanic_id) -} \ No newline at end of file +CREATE TABLE card_attack ( + card_attack_id INT PRIMARY KEY, + card_id INT NOT null, + attack_id INT NOT null, + card_attack_position INT not null +); + +CREATE TABLE energy_card ( + energy_card_id INT PRIMARY KEY, + energy_is_special BOOLEAN NOT NULL, + energy_main_type_id INT, + energy_effect_text TEXT, + card_id INT NOT NULL REFERENCES card(card_id) +); \ No newline at end of file