Обновить schema

This commit is contained in:
Fan
2026-09-29 11:20:26 +00:00
parent f53cb507f3
commit 4c2497c7a3
+133 -166
View File
@@ -1,186 +1,153 @@
Table card { CREATE TABLE card_set (
card_id int [primary key,not null] set_name VARCHAR(255) NOT NULL,
card_name text [not null] set_id VARCHAR(20) PRIMARY key not null,
card_rarity text set_series VARCHAR(20) NOT NULL,
card_number text [not null] set_total_cards INT NOT NULL,
card_artist text set_release_date DATE NOT null
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]
}
Table card_pokemon { INSERT INTO card_set (set_name, set_id, set_series, set_total_cards, set_release_date) VALUES
card_pokemon_id int [primary key, not null] ('XY Базовый набор', 'XY1', 'XY', 146, '2014-02-05'),
card_pokemon_hp int [not null, check: `card_hp > 0`] ('XY Огненная вспышка', 'XY2', 'XY', 106, '2014-05-07'),
card_pokemon_hieght numeric ('XY Яростный кулак', 'XY3', 'XY', 111, '2014-08-13'),
card_pokemon_weight numeric ('XY Призрачные силы', 'XY4', 'XY', 119, '2014-11-05'),
card_pokemon_name text [not null] ('XY Первобытная дуэль', 'XY5', 'XY', 160, '2015-02-04'),
card_pokemon_pokedex_entry_id int [not null] ('XY Грохочущие небеса', 'XY6', 'XY', 108, '2015-05-06'),
card_card_id int [primary key, not null] ('XY Древние истоки', 'XY7', 'XY', 98, '2015-08-12'),
card_pokemon_stage text [not null] ('XY Прорыв', 'XY8', 'XY', 162, '2015-11-04'),
card_pokemon_evloves_from text ('XY Тайное превосходство', 'XY9', 'XY', 122, '2016-02-03'),
card_pokemon_category text [not null] ('XY Столкновение судеб', 'XY10', 'XY', 124, '2016-05-02');
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]
} 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 { CREATE TABLE card_pokemon (
pokemon_sub_type_id int [primary key, not null, ref: - card_pokemon.card_pokemon_id] pokemon_card_id INT PRIMARY key,
pokemon_sub_type_name text [not null] pokemon_pokedex_number INT,
pokemon_sub_type_default_prize_count int [not null] pokemon_pokedex_entry_id INT,
pokemon_sub_type_global_rule_text text [not null] 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 { CREATE TABLE pokemon_species (
card_set_id int [primary key, not null] pokemon_species_pokedex_number INT PRIMARY KEY,
card_set_releaced_date date pokemon_species_end_name VARCHAR(150) NOT NULL,
card_set_name text [not null, unique] pokemon_species_generation INT NOT NULL,
card_set_code int [not null, unique] pokemon_species_height_m FLOAT NOT NULL,
card_set_total_cards int [not null, unique] pokemon_species_weight_kg FLOAT NOT NULL
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]
}
Table attack { CREATE TABLE pokemon_sub_type (
attack_id int [primary key, not null] sub_type_id INT PRIMARY KEY,
attack_name text [not null] sub_type_name VARCHAR(100) NOT NULL,
attack_base_damage text [null, check: `attack_base_damege >= 0`] sub_type_default_prize_count INT NOT NULL,
attack_effect text sub_type_global_rule_text TEXT NOT NULL
attack_retreat_cost int [null, check: `attack_retreat_cost >= 0`] );
}
Table card_attack { CREATE TABLE pokemon_ability (
card_attack_id int [primary key] ability_pokemon_card_id INT PRIMARY KEY,
card_id int [not null, ref: > card.card_id] ability_type_id INT NOT null,
attack_id int [not null, ref: > attack.attack_id] ability_name VARCHAR(150) NOT NULL,
card_attack_position int [null, check: `card_attack_position > 0`] ability_effect_text TEXT NOT NULL
} );
Table energy_type { CREATE TABLE pokemon_attack_link (
energy_quantily text [null] link_id INT PRIMARY KEY,
element_type_id int [primary key, not null] link_pokemon_card_id INT,
element_type_name text [not null, unique] link_attack_name_id INT,
energy_type_id int [not null, primary key] link_damage_value TEXT,
energy_type_icon_url text [not null] link_effect_text TEXT,
} UNIQUE (link_pokemon_card_id, link_attack_name_id)
);
Table illustrator { CREATE TABLE pokemon_attribute (
illustrator_name text [not null, unique] attribute_id INT PRIMARY KEY,
illustrator_id int [primary key, not null] attribute_pokemon_card_id INT NOT null,
illustrator_nationality text [null] attribute_energy_type_id INT NOT NULL,
illustrator_natinality twxt [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 { CREATE TABLE coach_card (
attack_energy_cost_id int [primary key] couch_card_id INT PRIMARY key,
attack_id int [not null] couch_printed_type_id INT,
element_type_id int [not null] couch_effect_text TEXT,
} couch_is_ace_spec BOOLEAN NOT null default false
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]
}
Table ability_type { CREATE TABLE trainer_mechanic_link (
ability_type_id int [primary key, not null] mechanic_link_trainer_card_id INT NOT null,
ability_type_name text [not null] mechanic_link_mechanic_id INT NOT null,
} PRIMARY KEY (mechanic_link_trainer_card_id, mechanic_link_mechanic_id)
);
Table attack_name { create table couch_printed_type (
attack_name_id int [primary key, not null] couch_type_id INT PRIMARY KEY,
attack_name_title text [not null] couch_type_name TEXT NOT NULL UNIQUE
} );
Table trainer_printed_type{ CREATE TABLE energy_type (
trainer_prinded_type_id int [primary key, not null, ref: - coach.coach_id] energy_type_id INT primary key,
trainer_printed_type_name text [not null] energy_type_name TEXT NOT NULL UNIQUE,
} energy_type_icon_url TEXT
);
Table game_mechanic { CREATE TABLE ability_type (
mechanic_id int [primary key, not null] ability_type_id INT PRIMARY KEY,
mechenic_name text [not null] ability_type_name TEXT NOT NULL
} );
Table pokemon_species { CREATE TABLE attack_name (
pokemon_species_pokedex_number int [not null, primary key, ref: - card_pokemon.card_pokemon_id] attack_name_id INT PRIMARY KEY,
pokemon_species_end_name text [not null] attack_name_title TEXT NOT NULL
pokemon_species_generetion int [not null] );
pokemon_species_height_m float [not null]
pokemon_species_weight_kg float [not null]
}
Table pokedex_entry { CREATE TABLE game_mechanic (
pokedex_entry_id int [not null, primary key, ref: - card_pokemon.card_pokemon_id] mechanic_id INT PRIMARY KEY,
pokedex_entry_pokedex_number int [not null] mechanic_name VARCHAR(150) NOT NULL
pokedex_entry_source_game text [not null] );
pokedex_entry_description text [not null]
}
Table energy_card { CREATE TABLE pokedex_entry (
energy_card_id int [not null, primary key, ref: - card.card_id] pokedex_entry_id INT PRIMARY KEY,
energy_is_special boolean [not null] pokedex_entry_pokedex_number INT NOT NULL,
energy_main_type_id int [null] pokedex_entry_source_game VARCHAR(100) NOT NULL,
energy_effect_text text [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 { CREATE TABLE attack_energy_cost (
link_id int [not null] attack_energy_cost_id INT PRIMARY KEY,
link_pokemon_card_id int [not null] attack_id INT NOT null,
link_attack_name_id int [not null] element_type_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]
}
}
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 { CREATE TABLE card_attack (
mechanic_link_trainer_card_id int [not null, ref: > game_mechanic.mechanic_id] card_attack_id INT PRIMARY KEY,
mechanic_link_mechanic_id int [not null] card_id INT NOT null,
primery key (mechanic_link_trainer_card_id, mechanic_link_mechanic_id) 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)
);