Обновить bsql-lab1.txt

This commit is contained in:
hhg
2026-09-09 12:54:12 +00:00
parent 797f1a8576
commit a139d6641b
+173 -84
View File
@@ -1,84 +1,173 @@
Table card { // # Глобальные справочники и Наборы (Сеты)
card_id int [primary key,not null] // Хранит информацию о выпусках/сетах карт. Позволяет группировать карты по хронологии и эпохам.
card_name text [not null] Table card_set {
card_rarity text set_id int [pk]
card_number text [not null] set_name text [unique] // Пример: 'XY Базовый набор', 'Древние Истоки'
card_artist text set_code text [unique] // Пример: 'XY1', 'XY2'
card_release_date date set_series text // Пример: 'XY', 'Черное и Белое'
card_image_url text set_total_cards int // Официальное количество карт в выпуске
card_set_id int [not null, ref: > card_set.card_set_id] set_release_date date
illustrator_id int [not null, ref: > illustrator.illustrator_id] set_logo_url text
card_pokemon_id int [not null, ref: - card_pokemon.card_pokemon_id] set_symbol_url text // Маленькая иконка сета на углу карты
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 energy_type {
energy_type_id int [pk]
Table card_pokemon { energy_type_name text [unique] // Пример: 'Grass', 'Fire', 'Colorless'
card_pokemon_id int [primary key, not null] energy_type_icon_url text
card_pokemon_hp int [not null, check: `card_hp > 0`] }
card_pokemon_hieght numeric
card_pokemon_weight numeric // Справочник особых классов покемонов (EX, MEGA, ex, VMAX), меняющих правила игры в зависимости от эпохи.
card_pokemon_name text [not null] Table pokemon_sub_type {
card_card_id int [primary key, not null] sub_type_id int [pk]
card_pokemon_stage text [not null] sub_type_name text [unique] // Пример: 'Normal', 'EX', 'MEGA'
card_pokemon_evloves_from text sub_type_default_prize_count int [default: 1] // Сколько призовых карт берет соперник за победу над этим покемоном (для EX — 2, для VMAX — 3)
card_pokemon_category text sub_type_global_rule_text text // Текст из рамки правил (Rule Box) на карте
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] Table ability_type {
} ability_type_id int [pk]
ability_type_name text [unique] // Пример: 'Ability', 'Poké-Power', 'Poké-Body'
Table card_set { }
card_set_id int [primary key, not null]
card_set_releaced_date date // Справочник уникальных названий атак, предотвращающий дублирование строк для повторяющихся приемов.
card_set_name text [not null, unique] Table attack_name {
card_set_code int [not null, unique] attack_name_id int [pk]
card_set_total_cards int [not null, unique] attack_name_title text [unique] // Пример: 'Hydro Pump', 'Slash'
} }
Table attack { // Скрытые правила для игрового движка.
attack_id int [primary key, not null] Table game_mechanic {
attack_name text [not null] mechanic_id int [pk]
attack_base_damage text [null, check: `attack_base_damege >= 0`] mechanic_name text [unique] // Пример: 'Is_Item', 'Is_Pokémon_Tool'
attack_effect text }
attack_retreat_cost int [null, check: `attack_retreat_cost >= 0`]
}
// # Глобальный Покедекс (Реестр существ)
Table card_attack { // Глобальный реестр существ, единый для всех наборов и карт. Хранит эталонные параметры лора.
card_attack_id int [primary key] Table pokemon_species {
card_id int [not null, ref: > card.card_id] species_pokedex_number int [pk] // Национальный номер (например, 25 для Пикачу, 652 для Чеснота)
attack_id int [not null, ref: > attack.attack_id] species_eng_name text [unique] // Английское имя покемона.
card_attack_position int [null, check: `card_attack_position > 0`] species_generation int // Номер поколения, где покемон появился впервые (например, 6 для эпохи XY)
} species_height_m numeric // Официальный рост покемона в метрах
species_weight_kg numeric // Официальный вес покемона в килограммах
Table energy_type { }
energy_quantily text [null]
element_type_id int [primary key, not null] // Хранит все варианты художественных описаний покемонов из разных видеоигр.
element_type_name text [not null, unique] Table pokedex_entry {
energy_type_id int [not null, primary key] entry_id int [pk]
} entry_pokedex_number int
entry_source_game text // Видеоигра, откуда взят текст (Пример: 'Pokémon X')
Table illustrator { entry_description text // Художественное описание покемона
illustrator_name text [not null, unique] }
illustrator_id int [primary key, not null]
illustrator_nationality text [null]
illustrator_natinality twxt [null] // # Главная (Родительская) таблица карт
} // Базовый класс. Любая физическая карта сначала создается здесь. Хранит только общие метаданные.
Table card {
Table attack_energy_cost { card_id int [pk]
attack_energy_cost_id int [primary key] card_number text [unique] // Номер карты на картонке (Пример: '14/146', 'XY99')
attack_id int [not null] card_set_id int [unique]
element_type_id int [not null] card_name text
} card_rarity text // Пример: 'Common', 'Ultra Rare'
Table coach { card_type text [check: `card_type == "Pokemon" OR card_type == "Trainer" OR card_type == "Energy"`] // Указывает, в какую дочернюю таблицу идти за деталями
coach_id int [primary key, not null] card_image_url text
coach_name text [not null, unique] // Ограничение уникальности: Составной ключ (card_set_id, card_number)
coach_type int [not null] }
coach_releaced_date date [not null]
coach_skill text [not null]
coach_description text [not null] // # Специфичные (Дочерние) таблицы (Связь 1-к-1 с таблицей card)
coach_rarity text [not null] // Расширяет базовую карту боевыми характеристиками покемона
coach_image_url text [not null] Table pokemon_card {
} pokemon_card_id int [pk]
pokemon_pokedex_number int
pokemon_pokedex_entry_id int // (Может быть NULL для карт класса EX/ex)
pokemon_hp int [check: `pokemon_hp % 10 == 0`] // Очки здоровья, всегда кратны 10 (например, 160)
pokemon_stage text [not null] // (Пример: 'Basic', 'Stage 1', 'MEGA')
pokemon_evolves_from text // (Имя покемона; NULL для базовых карт)
pokemon_retreat_cost int // Количество бесцветных энергий, необходимых для побега (от 0 до 4)
pokemon_sub_type_id int
pokemon_category text // Декоративный текст (Пример: 'Пыльный мотылёк')
pokemon_printed_height text // Рост, как он написан на карте (Пример: '1,5 м' или '4'11"')
pokemon_printed_weight text // Вес, как он написан на карте (Пример: '90,0 кг' или '198.4 lbs')
}
// Расширяет базовую карту свойствами предметов и поддержки.
Table trainer_card {
trainer_card_id int [pk]
trainer_printed_type_id int
trainer_effect_text text // Что карта делает при розыгрыше
trainer_is_ace_spec bool // Ограничение: максимум 1 карта класса ACE SPEC на колоду
}
// Расширяет базовую карту свойствами источников энергии.
Table energy_card {
energy_card_id int [pk]
energy_is_special bool // True — для особых карт (лимит 4 копии), False — для базовых энергий (без лимита)
energy_main_type_id int // NULL для особых карт, дающих энергию любого типа
}
// # Таблицы связей характеристик покемонов и тренеров
// Пассивные умения покемонов (Абилити). Связь 1-к-1 с карта_покемона (у покемона способность либо одна, либо ее нет).
Table pokemon_ability {
ability_pokemon_card_id int [pk]
ability_type_id int
ability_name text // Пример: 'Колючая броня'
ability_effect_text text // Что делает пассивный навык
}
// Промежуточная таблица (Многие-ко-Многому). Связывает конкретного покемона со справочником имен атак. Урон и текст хранятся здесь, так как атаки с одним именем («Slash») наносят разный урон у разных покемонов.
Table pokemon_attack_link {
link_id int [pk] // связь_покемон_атака_идентификатор_связи. К этому ID привязывается стоимость атаки
link_pokemon_card_id int [unique]
link_attack_name_id int [unique]
link_damage_value text // Урон атаки (строка нужна для поддержки символов вроде '50+' или '30x')
link_effect_text text // Условия атаки (например, «подкиньте монетку»)
}
// Определяет, сколько и какой энергии нужно для активации конкретной атаки у конкретного покемона.
Table attack_energy_cost {
cost_id int [pk]
cost_link_id int // стоимость_энергии_атаки_связь_покемон_атака_ид
cost_energy_type_id int
cost_quantity int [default: 1] // Количество энергии (например, 3 единицы Огня)
}
Table pokemon_attribute {
attribute_id int [pk]
attribute_pokemon_card_id int [unique]
attribute_energy_type_id int [unique]
attribute_kind enum [unique] // Значения: 'Weakness' (Слабость) или 'Resistance' (Сопротивление)
attribute_modifier_value text // Обозначение изменения урона (Пример: 'x2', '-20', '-30')
}
Ref: "pokedex_entry"."entry_pokedex_number" ?>? "pokemon_species"."species_pokedex_number"
Ref: "card"."card_set_id" -? "card_set"."set_id"
Ref: "card"."card_id" -? "pokemon_card"."pokemon_card_id"
Ref: "pokemon_card"."pokemon_pokedex_number" ?>? "pokemon_species"."species_pokedex_number"
Ref: "pokemon_card"."pokemon_pokedex_entry_id" ?<>? "pokedex_entry"."entry_description"
Ref: "pokemon_card"."pokemon_sub_type_id" ?>? "pokemon_sub_type"."sub_type_id"
Ref: "card"."card_id" -? "trainer_card"."trainer_card_id"
Ref: "card"."card_id" -? "energy_card"."energy_card_id"
Ref: "energy_card"."energy_main_type_id" ?>? "energy_type"."energy_type_id"
Ref: "pokemon_ability"."ability_type_id" ?>? "ability_type"."ability_type_id"
Ref: "pokemon_card"."pokemon_card_id" -? "pokemon_ability"."ability_pokemon_card_id"
Ref: "pokemon_card"."pokemon_card_id" ?-? "pokemon_attack_link"."link_pokemon_card_id"
Ref: "attack_name"."attack_name_id" ?-? "pokemon_attack_link"."link_attack_name_id"
Ref: "attack_energy_cost"."cost_link_id" ?>? "pokemon_attack_link"."link_id"
Ref: "attack_energy_cost"."cost_energy_type_id" ?>? "energy_type"."energy_type_id"
Ref: "pokemon_card"."pokemon_card_id" ?-? "pokemon_attribute"."attribute_pokemon_card_id"
Ref: "energy_type"."energy_type_id" ?-? "pokemon_attribute"."attribute_energy_type_id"