generated from admin/template
schema
This commit is contained in:
+191
@@ -0,0 +1,191 @@
|
|||||||
|
# Лабораторная работа "SCHEMA"
|
||||||
|
|
||||||
|
* **Студент:** Закиров Алим Альбертович
|
||||||
|
* **Вариант / Карточка:** schema
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ключевой код
|
||||||
|
```csharp
|
||||||
|
// ГЛОБАЛЬНЫЕ СПРАВОЧНИКИ И НАБОРЫ
|
||||||
|
|
||||||
|
Table card_set {
|
||||||
|
set_id integer [primary key, not null, unique]
|
||||||
|
set_name text [not null]
|
||||||
|
set_code text [not null, unique]
|
||||||
|
set_series text [not null]
|
||||||
|
set_total_cards int [not null, check: `set_total_cards > 0`]
|
||||||
|
set_release_date date [not null]
|
||||||
|
set_logo_url text
|
||||||
|
set_symbol_url text
|
||||||
|
}
|
||||||
|
|
||||||
|
Table energy_type {
|
||||||
|
energy_type_id integer [primary key, not null, unique]
|
||||||
|
energy_type_name text [not null, unique]
|
||||||
|
energy_type_icon_url text
|
||||||
|
}
|
||||||
|
|
||||||
|
Table pokemon_sub_type {
|
||||||
|
sub_type_id int [primary key, not null, unique]
|
||||||
|
sub_type_name text [unique, not null]
|
||||||
|
sub_type_default_prize_count int [not null, check: `sub_type_default_prize_count >= 1`]
|
||||||
|
sub_type_global_rule_text text [not null]
|
||||||
|
}
|
||||||
|
|
||||||
|
Table ability_type {
|
||||||
|
ability_type_id int [not null, pk, unique]
|
||||||
|
ability_type_name text [not null, unique]
|
||||||
|
}
|
||||||
|
|
||||||
|
Table attack_name {
|
||||||
|
attack_name_id integer [primary key, not null, unique]
|
||||||
|
attack_name_title text [not null, unique]
|
||||||
|
}
|
||||||
|
|
||||||
|
Table trainer_printed_type {
|
||||||
|
printed_type_id int [pk, not null, unique]
|
||||||
|
printed_type_name text [not null, unique]
|
||||||
|
}
|
||||||
|
|
||||||
|
Table game_mechanic {
|
||||||
|
mechanic_id int [pk, not null, unique]
|
||||||
|
mechanic_name text [not null, unique]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ГЛОБАЛЬНЫЙ ПОКЕДЕКС
|
||||||
|
|
||||||
|
Table pokemon_species {
|
||||||
|
species_pokedex_number int [pk, not null, unique]
|
||||||
|
species_eng_name text [unique]
|
||||||
|
species_generation int [not null]
|
||||||
|
species_height_m float [not null, check: `species_height_m > 0`]
|
||||||
|
species_weight_kg float [not null, check: `species_weight_kg > 0`]
|
||||||
|
}
|
||||||
|
|
||||||
|
Table pokedex_entry {
|
||||||
|
entry_id int [pk, not null, unique]
|
||||||
|
entry_pokedex_number int [not null]
|
||||||
|
entry_source_game text [not null]
|
||||||
|
entry_description text [not null]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// РОДИТЕЛЬСКАЯ ТАБЛИЦА КАРД
|
||||||
|
|
||||||
|
Table card {
|
||||||
|
card_id integer [primary key, not null, unique]
|
||||||
|
card_number text [not null, unique]
|
||||||
|
card_set_id integer [not null]
|
||||||
|
card_rarity text [not null]
|
||||||
|
card_type text [not null]
|
||||||
|
card_image_url text
|
||||||
|
energy_type_id integer [not null]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ДОЧЕРНИЕ ТАБЛИЦЫ
|
||||||
|
|
||||||
|
Table pokemon_card {
|
||||||
|
pokemon_card_id int [pk, unique, not null]
|
||||||
|
pokemon_pokedex_number int [not null]
|
||||||
|
pokemon_pokedex_entry_id int
|
||||||
|
pokemon_hp int [not null]
|
||||||
|
pokemon_stage text [not null]
|
||||||
|
pokemon_evolves_from text
|
||||||
|
pokemon_retreat_cost int [not null]
|
||||||
|
pokemon_sub_type_id int [not null]
|
||||||
|
pokemon_category text [not null]
|
||||||
|
pokemon_printed_height text [not null]
|
||||||
|
pokemon_printed_weight text [not null]
|
||||||
|
}
|
||||||
|
|
||||||
|
Table trainer_card {
|
||||||
|
trainer_card_id int [pk, not null, unique]
|
||||||
|
trainer_printed_type_id int [not null]
|
||||||
|
trainer_effect_text text [not null]
|
||||||
|
trainer_is_ace_spec bool [not null]
|
||||||
|
}
|
||||||
|
|
||||||
|
Table energy_card {
|
||||||
|
energy_card_id int [pk, not null, unique]
|
||||||
|
energy_is_special bool [not null]
|
||||||
|
energy_main_type_id int
|
||||||
|
energy_effect_text text
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ТАБЛИЦЫ СВЯЗЕЙ ХАРАКТЕРИСТИК ПОКЕМОНОВ И ТРЕНЕРОВ
|
||||||
|
|
||||||
|
Table pokemon_ability {
|
||||||
|
ability_pokemon_card_id int [pk, not null, unique]
|
||||||
|
ability_type_id int [not null]
|
||||||
|
ability_name text [not null]
|
||||||
|
anility_effect_text text [not null]
|
||||||
|
}
|
||||||
|
|
||||||
|
Table pokemon_attack_link {
|
||||||
|
link_id int [pk, unique, not null]
|
||||||
|
link_pokemon_card_id int [not null]
|
||||||
|
link_attack_name_id int [not null]
|
||||||
|
link_damage_value varchar [not null]
|
||||||
|
link_effect_text text
|
||||||
|
|
||||||
|
indexes {
|
||||||
|
(link_pokemon_card_id, link_attack_name_id) [unique]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Table attack_energy_cost {
|
||||||
|
cost_id int [pk, unique, not null]
|
||||||
|
cost_link_id int [not null]
|
||||||
|
cost_energy_type_id int [not null]
|
||||||
|
cost_quantity int [default: 1, not null]
|
||||||
|
}
|
||||||
|
|
||||||
|
Table pokemon_attribute {
|
||||||
|
attribute_id int [pk, unique, not null]
|
||||||
|
attribute_pokemon_card_id int [not null]
|
||||||
|
attribute_energy_type_id int [not null]
|
||||||
|
attribute_kind varchar [not null]
|
||||||
|
attribute_modifier_value varchar [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]
|
||||||
|
mechanic_link_mechanic_id int [not null]
|
||||||
|
|
||||||
|
indexes {
|
||||||
|
(mechanic_link_trainer_card_id, mechanic_link_mechanic_id) [pk]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// СВЯЗИ МЕЖДУ ТАБЛИЦАМИ
|
||||||
|
|
||||||
|
Ref: card_set.set_id < card.card_set_id
|
||||||
|
Ref: energy_type.energy_type_id < card.energy_type_id
|
||||||
|
Ref: pokemon_species.species_pokedex_number < pokedex_entry.entry_pokedex_number
|
||||||
|
Ref: card.card_id - pokemon_card.pokemon_card_id
|
||||||
|
Ref: card.card_id - trainer_card.trainer_card_id
|
||||||
|
Ref: card.card_id - energy_card.energy_card_id
|
||||||
|
Ref: pokemon_species.species_pokedex_number < pokemon_card.pokemon_pokedex_number
|
||||||
|
Ref: pokedex_entry.entry_id < pokemon_card.pokemon_pokedex_entry_id
|
||||||
|
Ref: pokemon_sub_type.sub_type_id < pokemon_card.pokemon_sub_type_id
|
||||||
|
Ref: ability_type.ability_type_id < pokemon_ability.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: pokemon_attack_link.link_id < attack_energy_cost.cost_link_id
|
||||||
|
Ref: energy_type.energy_type_id < attack_energy_cost.cost_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
|
||||||
|
Ref: trainer_printed_type.printed_type_id < trainer_card.trainer_printed_type_id
|
||||||
|
Ref: trainer_card.trainer_card_id < trainer_mechanic_link.mechanic_link_trainer_card_id
|
||||||
|
Ref: game_mechanic.mechanic_id < trainer_mechanic_link.mechanic_link_mechanic_id
|
||||||
|
Ref: energy_type.energy_type_id < energy_card.energy_main_type_id
|
||||||
Reference in New Issue
Block a user