From a139d6641b42bbb044c85176f89a2444d3fd09c1 Mon Sep 17 00:00:00 2001 From: hhg Date: Wed, 9 Sep 2026 12:54:12 +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=20bsql-lab1.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsql-lab1.txt | 257 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 173 insertions(+), 84 deletions(-) diff --git a/bsql-lab1.txt b/bsql-lab1.txt index 67fa88b..9042de8 100644 --- a/bsql-lab1.txt +++ b/bsql-lab1.txt @@ -1,84 +1,173 @@ -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_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, 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 { - 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_card_id int [primary key, not null] - card_pokemon_stage text [not null] - card_pokemon_evloves_from text - card_pokemon_category text - 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 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] -} - -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`] -} - -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`] -} - -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] -} - -Table illustrator { - illustrator_name text [not null, unique] - illustrator_id int [primary key, not null] - illustrator_nationality text [null] - illustrator_natinality twxt [null] -} - -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] -} \ No newline at end of file +// # Глобальные справочники и Наборы (Сеты) +// Хранит информацию о выпусках/сетах карт. Позволяет группировать карты по хронологии и эпохам. +Table card_set { + set_id int [pk] + set_name text [unique] // Пример: 'XY Базовый набор', 'Древние Истоки' + set_code text [unique] // Пример: 'XY1', 'XY2' + set_series text // Пример: 'XY', 'Черное и Белое' + set_total_cards int // Официальное количество карт в выпуске + set_release_date date + set_logo_url text + set_symbol_url text // Маленькая иконка сета на углу карты +} + +// Справочник стихий/элементов (Трава, Огонь, Вода и т.д.). Исключает опечатки в названиях типов. +Table energy_type { + energy_type_id int [pk] + energy_type_name text [unique] // Пример: 'Grass', 'Fire', 'Colorless' + energy_type_icon_url text +} + +// Справочник особых классов покемонов (EX, MEGA, ex, VMAX), меняющих правила игры в зависимости от эпохи. +Table pokemon_sub_type { + sub_type_id int [pk] + sub_type_name text [unique] // Пример: 'Normal', 'EX', 'MEGA' + sub_type_default_prize_count int [default: 1] // Сколько призовых карт берет соперник за победу над этим покемоном (для EX — 2, для VMAX — 3) + sub_type_global_rule_text text // Текст из рамки правил (Rule Box) на карте +} + +// Справочник видов пассивных умений покемонов. +Table ability_type { + ability_type_id int [pk] + ability_type_name text [unique] // Пример: 'Ability', 'Poké-Power', 'Poké-Body' +} + +// Справочник уникальных названий атак, предотвращающий дублирование строк для повторяющихся приемов. +Table attack_name { + attack_name_id int [pk] + attack_name_title text [unique] // Пример: 'Hydro Pump', 'Slash' +} + +// Скрытые правила для игрового движка. +Table game_mechanic { + mechanic_id int [pk] + mechanic_name text [unique] // Пример: 'Is_Item', 'Is_Pokémon_Tool' +} + + +// # Глобальный Покедекс (Реестр существ) +// Глобальный реестр существ, единый для всех наборов и карт. Хранит эталонные параметры лора. +Table pokemon_species { + species_pokedex_number int [pk] // Национальный номер (например, 25 для Пикачу, 652 для Чеснота) + species_eng_name text [unique] // Английское имя покемона. + species_generation int // Номер поколения, где покемон появился впервые (например, 6 для эпохи XY) + species_height_m numeric // Официальный рост покемона в метрах + species_weight_kg numeric // Официальный вес покемона в килограммах +} + +// Хранит все варианты художественных описаний покемонов из разных видеоигр. +Table pokedex_entry { + entry_id int [pk] + entry_pokedex_number int + entry_source_game text // Видеоигра, откуда взят текст (Пример: 'Pokémon X') + entry_description text // Художественное описание покемона +} + + +// # Главная (Родительская) таблица карт +// Базовый класс. Любая физическая карта сначала создается здесь. Хранит только общие метаданные. +Table card { + card_id int [pk] + card_number text [unique] // Номер карты на картонке (Пример: '14/146', 'XY99') + card_set_id int [unique] + card_name text + card_rarity text // Пример: 'Common', 'Ultra Rare' + card_type text [check: `card_type == "Pokemon" OR card_type == "Trainer" OR card_type == "Energy"`] // Указывает, в какую дочернюю таблицу идти за деталями + card_image_url text + // Ограничение уникальности: Составной ключ (card_set_id, card_number) +} + + +// # Специфичные (Дочерние) таблицы (Связь 1-к-1 с таблицей card) +// Расширяет базовую карту боевыми характеристиками покемона +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" \ No newline at end of file