Compare commits

..
6 Commits
Author SHA1 Message Date
maonanhai b95346519f add Readme for lab-03 with student details and SQL tasks 2026-09-28 15:13:18 +03:00
maonanhai 63464bcb52 lesson2 added 2026-09-17 01:37:16 +03:00
maonanhai 096c134bb8 refactoring 2026-09-17 01:08:23 +03:00
maonanhai 8ecee8583a schema 2026-09-09 15:50:48 +03:00
maonanhai 27083475b1 improvements 2026-09-07 14:05:38 +03:00
maonanhai acb72351f7 correction 2026-09-07 13:54:38 +03:00
9 changed files with 533 additions and 154 deletions
+1
View File
@@ -3,5 +3,6 @@
* **Курс:** base-sql * **Курс:** base-sql
## Список работ ## Список работ
* [Лабораторная работа №0](./works/lab-00)
* [Лабораторная работа №1](./works/lab-01) * [Лабораторная работа №1](./works/lab-01)
* [Лабораторная работа №2](./works/lab-02) * [Лабораторная работа №2](./works/lab-02)
+4
View File
@@ -0,0 +1,4 @@
# Лабораторная работа №0
* **Студент:** Закиров Алим Альбертович
* **Вариант / Карточка:** Первичные и внешние ключи, ограничения целостности базы данных «Pokémon TCG»
+78
View File
@@ -0,0 +1,78 @@
```csharp
Table card {
card_id integer [primary key]
card_name text
card_stage text
card_hp integer
card_num_in_pokedex integer
card_type text
card_height integer
card_weight integer
card_retreat_cost integer
card_release_year date
card_set_id integer [not null]
attack_id integer [not null]
element_type_id integer [not null]
illustrator_id integer [not null]
}
Table card_set {
card_set_id integer [primary key]
card_set_name text
card_set_total_quantity integer
card_set_release_year date
}
Table attack {
attack_id integer [primary key]
attack_name text
attack_base_damage integer
attack_effect text
}
Table element_type {
element_type_id integer [primary key]
element_type_name text
}
Table illustrator {
illustrator_id integer [primary key]
illustrator_name text
}
Ref: card_set.card_set_id < card.card_set_id
Ref: attack.attack_id < card.attack_id
Ref: element_type.element_type_id < card.element_type_id
Ref: illustrator.illustrator_id < card.illustrator_id
// Записи(значения сделаны с помощью ИИ):
Records card_set(card_set_id, card_set_name, card_set_total_quantity, card_set_release_year) {
0, 'Base Set', 102, '1999-01-09'
1, 'Jungle', 64, '1999-06-16'
2, 'Fossil', 62, '1999-10-10'
}
Records attack(attack_id, attack_name, attack_base_damage, attack_effect) {
0, 'Thunder Shock', 10, 'Flip a coin. If tails, this attack does nothing.'
1, 'Vine Whip', 35, null
2, 'Ember', 30, 'Discard 1 Energy card attached to this Pokemon.'
}
Records element_type(element_type_id, element_type_name) {
0, 'Lightning'
1, 'Grass'
2, 'Fire'
}
Records illustrator(illustrator_id, illustrator_name) {
0, 'Mitsuhiro Arita'
1, 'Ken Sugimori'
2, 'Keiji Kinebuchi'
}
Records card(card_id, card_name, card_stage, card_hp, card_num_in_pokedex, card_type, card_height, card_weight, card_retreat_cost, card_release_year, card_set_id, attack_id, element_type_id, illustrator_id) {
0, 'Pikachu', 'Basic', 40, 25, 'Lightning', 4, 60, 1, '1999-01-09', 0, 0, 0, 0
1, 'Bulbasaur', 'Basic', 40, 1, 'Grass', 7, 69, 1, '1999-06-16', 1, 1, 1, 1
2, 'Charmander', 'Basic', 50, 4, 'Fire', 6, 85, 1, '1999-10-10', 2, 2, 2, 2
}
+1 -83
View File
@@ -1,86 +1,4 @@
# Лабораторная работа №1 # Лабораторная работа №1
* **Студент:** Закиров Алим Альбертович * **Студент:** Закиров Алим Альбертович
* **Вариант / Карточка:** Первичные и внешние ключи, ограничения целостности базы данных «Pokémon TCG» * **Вариант / Карточка:** Проектирование ER-диаграммы базы данных «Pokémon TCG» в dbdiagram.io
---
## Ключевой код
```csharp
Table card {
card_id integer [primary key]
card_name text
card_stage text
card_hp integer
card_num_in_pokedex integer
card_type text
card_height integer
card_weight integer
card_retreat_cost integer
card_release_year date
card_set_id integer [not null]
attack_id integer [not null]
element_type_id integer [not null]
illustrator_id integer [not null]
}
Table card_set {
card_set_id integer [primary key]
card_set_name text
card_set_total_quantity integer
card_set_release_year date
}
Table attack {
attack_id integer [primary key]
attack_name text
attack_base_damage integer
attack_effect text
}
Table element_type {
element_type_id integer [primary key]
element_type_name text
}
Table illustrator {
illustrator_id integer [primary key]
illustrator_name text
}
Ref: card_set.card_set_id < card.card_set_id
Ref: attack.attack_id < card.attack_id
Ref: element_type.element_type_id < card.element_type_id
Ref: illustrator.illustrator_id < card.illustrator_id
// Записи(значения сделаны с помощью ИИ):
Records card_set(card_set_id, card_set_name, card_set_total_quantity, card_set_release_year) {
0, 'Base Set', 102, '1999-01-09'
1, 'Jungle', 64, '1999-06-16'
2, 'Fossil', 62, '1999-10-10'
}
Records attack(attack_id, attack_name, attack_base_damage, attack_effect) {
0, 'Thunder Shock', 10, 'Flip a coin. If tails, this attack does nothing.'
1, 'Vine Whip', 35, null
2, 'Ember', 30, 'Discard 1 Energy card attached to this Pokemon.'
}
Records element_type(element_type_id, element_type_name) {
0, 'Lightning'
1, 'Grass'
2, 'Fire'
}
Records illustrator(illustrator_id, illustrator_name) {
0, 'Mitsuhiro Arita'
1, 'Ken Sugimori'
2, 'Keiji Kinebuchi'
}
Records card(card_id, card_name, card_stage, card_hp, card_num_in_pokedex, card_type, card_height, card_weight, card_retreat_cost, card_release_year, card_set_id, attack_id, element_type_id, illustrator_id) {
0, 'Pikachu', 'Basic', 40, 25, 'Lightning', 4, 60, 1, '1999-01-09', 0, 0, 0, 0
1, 'Bulbasaur', 'Basic', 40, 1, 'Grass', 7, 69, 1, '1999-06-16', 1, 1, 1, 1
2, 'Charmander', 'Basic', 50, 4, 'Fire', 6, 85, 1, '1999-10-10', 2, 2, 2, 2
}
@@ -0,0 +1,72 @@
```csharp
Table card {
card_id integer [primary key, not null, unique]
card_name text [not null]
card_stage text [not null]
card_hp integer [not null, check: `card_hp > 0`]
card_num_in_pokedex integer [not null]
card_type text [not null]
card_height integer [not null, check: `card_height > 0`]
card_weight integer [not null, check: `card_weight > 0`]
card_retreat_cost integer [not null, check: `card_retreat_cost >= 0`]
card_release_date date [not null]
card_set_id integer [not null]
element_type_id integer [not null]
illustrator_id integer [not null]
}
Table card_set {
card_set_id integer [primary key, not null, unique]
card_set_name text [not null]
card_set_total_quantity integer [not null, check: `card_set_total_quantity > 0`]
card_set_release_date date [not null]
}
Table attack {
attack_id integer [primary key, not null, unique]
attack_name text [not null]
attack_base_damage integer [not null, check: `attack_base_damage >= 0`]
attack_damage_modifier text
attack_effect text
}
Table element_type {
element_type_id integer [primary key, not null, unique]
element_type_name text [not null]
}
Table illustrator {
illustrator_id integer [primary key, not null, unique]
illustrator_name text [not null]
}
Table attack_card {
attack_card_id int [pk, not null, unique]
card_id int [not null]
attack_id int [not null]
indexes {
(card_id, attack_id) [unique]
}
}
Table attack_card_pricing {
attack_card_pricing_id int [pk, not null, unique]
attack_card_pricing_cost int [not null, check: `attack_card_pricing_cost >= 0`]
attack_card_id int [not null]
element_type_id int [not null]
indexes {
(attack_card_id, element_type_id) [unique]
}
}
Ref: card_set.card_set_id < card.card_set_id
Ref: element_type.element_type_id < card.element_type_id
Ref: illustrator.illustrator_id < card.illustrator_id
Ref: card.card_id < attack_card.card_id
Ref: attack.attack_id > attack_card.attack_id
Ref: attack_card_pricing.attack_card_id < attack_card.attack_card_id
Ref: element_type.element_type_id < attack_card_pricing.element_type_id
+1 -71
View File
@@ -1,74 +1,4 @@
# Лабораторная работа №2 # Лабораторная работа №2
* **Студент:** Закиров Алим Альбертович * **Студент:** Закиров Алим Альбертович
* **Вариант / Карточка:** Проектирование связей "Многие-ко-Многим" * **Вариант / Карточка:** Реализация базы данных «Pokémon TCG» в SQL DDL и рефакторинг под типы карт
---
## Ключевой код
```csharp
Table card {
card_id integer [primary key, not null, unique]
card_name text [not null]
card_stage text [not null]
card_hp integer [not null, check: `card_hp > 0`]
card_num_in_pokedex integer [not null]
card_type text [not null]
card_height integer [not null, check: `card_height > 0`]
card_weight integer [not null, check: `card_weight > 0`]
card_retreat_cost integer [not null, check: `card_retreat_cost >= 0`]
card_release_date date [not null]
card_set_id integer [not null]
attack_id integer [not null]
element_type_id integer [not null]
illustrator_id integer [not null]
}
Table card_set {
card_set_id integer [primary key, not null, unique]
card_set_name text [not null]
card_set_total_quantity integer [not null, check: `card_set_total_quantity > 0`]
card_set_release_date date [not null]
}
Table attack {
attack_id integer [primary key, not null, unique]
attack_name text [not null]
attack_base_damage integer [not null, check: `attack_base_damage >= 0`]
attack_damage_modifier text
attack_effect text
}
Table element_type {
element_type_id integer [primary key, not null, unique]
element_type_name text [not null]
}
Table illustrator {
illustrator_id integer [primary key, not null, unique]
illustrator_name text [not null]
}
Table attack_card {
attack_card_id int [pk, not null, unique]
card_id int [not null]
attack_id int [not null]
}
Table attack_card_prining {
attack_card_prining_id int [pk, not null, unique]
attack_card_prining_cost int [not null, check: `attack_card_pricing_cost >= 0`]
attack_card_id int [not null]
element_type_id int [not null]
}
Ref: card_set.card_set_id < card.card_set_id
Ref: attack.attack_id < card.attack_id
Ref: element_type.element_type_id < card.element_type_id
Ref: illustrator.illustrator_id < card.illustrator_id
Ref: card.card_id > attack_card.card_id
Ref: attack.attack_id > attack_card.attack_id
Ref: attack_card_prining.attack_card_id < attack_card.attack_card_id
Ref: element_type.element_type_id < attack_card_prining.element_type_id
+181
View File
@@ -0,0 +1,181 @@
-- 1. СПРАВОЧНИКИ
CREATE TABLE "card_set" (
"card_set_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"set_name" TEXT NOT NULL,
"set_code" TEXT UNIQUE NOT NULL,
"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
);
CREATE TABLE "energy_type" (
"energy_type_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"energy_type_name" TEXT UNIQUE NOT NULL,
"energy_type_icon_url" TEXT
);
CREATE TABLE "pokemon_sub_type" (
"pokemon_sub_type_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"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
);
CREATE TABLE "ability_type" (
"ability_type_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"ability_type_name" TEXT UNIQUE NOT NULL
);
CREATE TABLE "attack_name" (
"attack_name_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"attack_name_title" TEXT UNIQUE NOT NULL
);
CREATE TABLE "trainer_printed_type" (
"trainer_printed_type_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"printed_type_name" TEXT UNIQUE NOT NULL
);
CREATE TABLE "game_mechanic" (
"game_mechanic_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"mechanic_name" TEXT UNIQUE NOT NULL
);
-- 2. ГЛОБАЛЬНЫЙ ПОКЕДЕКС
CREATE TABLE "pokemon_species" (
"species_pokedex_number" INT PRIMARY KEY,
"species_eng_name" TEXT UNIQUE,
"species_generation" INT NOT NULL,
"species_height_m" NUMERIC(5,2) NOT NULL CHECK (species_height_m > 0),
"species_weight_kg" NUMERIC(5,2) NOT NULL CHECK (species_weight_kg > 0)
);
CREATE TABLE "pokedex_entry" (
"entry_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"entry_pokedex_number" INT NOT NULL,
"entry_source_game" TEXT NOT NULL,
"entry_description" TEXT NOT NULL
);
-- 3. РОДИТЕЛЬСКАЯ ТАБЛИЦА КАРТ
CREATE TABLE "card" (
"card_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"card_number" TEXT UNIQUE NOT NULL,
"card_set_id" INT NOT NULL,
"card_rarity" TEXT NOT NULL,
"card_type" TEXT NOT NULL CHECK (card_type IN ('pokemon', 'energy', 'trainer')),
"card_image_url" TEXT
);
-- 4. ДОЧЕРНИЕ ТАБЛИЦЫ ПО ТИПАМ КАРТ
CREATE TABLE "pokemon_card" (
"pokemon_card_id" INT PRIMARY KEY,
"pokemon_pokedex_number" INT NOT NULL,
"pokemon_pokedex_entry_id" INT,
"pokemon_hp" INT NOT NULL CHECK (pokemon_hp > 0),
"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,
"energy_type_id" INT NOT NULL
);
CREATE TABLE "trainer_card" (
"trainer_card_id" INT PRIMARY KEY,
"trainer_printed_type_id" INT NOT NULL,
"trainer_effect_text" TEXT NOT NULL,
"trainer_is_ace_spec" BOOL NOT NULL
);
CREATE TABLE "energy_card" (
"energy_card_id" INT PRIMARY KEY,
"energy_is_special" BOOL NOT NULL,
"energy_main_type_id" INT,
"energy_effect_text" TEXT
);
-- 5. СВЯЗИ ХАРАКТЕРИСТИК ПОКЕМОНОВ И ТРЕНЕРОВ
CREATE TABLE "pokemon_ability" (
"ability_pokemon_card_id" INT PRIMARY KEY,
"ability_type_id" INT NOT NULL,
"ability_name" TEXT NOT NULL,
"ability_effect_text" TEXT NOT NULL
);
CREATE TABLE "pokemon_attack_link" (
"link_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"link_pokemon_card_id" INT NOT NULL,
"link_attack_name_id" INT NOT NULL,
"link_damage_value" TEXT NOT NULL,
"link_effect_text" TEXT
);
CREATE TABLE "attack_energy_cost" (
"cost_id" INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
"cost_link_id" INT NOT NULL,
"cost_energy_type_id" INT NOT NULL,
"cost_quantity" INT NOT NULL DEFAULT 1
);
CREATE TABLE "pokemon_attribute" (
"attribute_id" INT GENERATED ALWAYS AS IDENTITY 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
);
CREATE TABLE "trainer_mechanic_link" (
"mechanic_link_trainer_card_id" INT NOT NULL,
"mechanic_link_game_mechanic_id" INT NOT NULL,
PRIMARY KEY ("mechanic_link_trainer_card_id", "mechanic_link_game_mechanic_id")
);
-- 6. УНИКАЛЬНЫЕ ИНДЕКСЫ
CREATE UNIQUE INDEX ON "pokemon_attack_link" ("link_pokemon_card_id", "link_attack_name_id");
CREATE UNIQUE INDEX ON "pokemon_attribute" ("attribute_pokemon_card_id", "attribute_energy_type_id", "attribute_kind");
-- 7. ВНЕШНИЕ КЛЮЧИ
ALTER TABLE "card" ADD FOREIGN KEY ("card_set_id") REFERENCES "card_set" ("card_set_id");
ALTER TABLE "pokedex_entry" ADD FOREIGN KEY ("entry_pokedex_number") REFERENCES "pokemon_species" ("species_pokedex_number");
ALTER TABLE "pokemon_card" ADD FOREIGN KEY ("pokemon_card_id") REFERENCES "card" ("card_id");
ALTER TABLE "trainer_card" ADD FOREIGN KEY ("trainer_card_id") REFERENCES "card" ("card_id");
ALTER TABLE "energy_card" ADD FOREIGN KEY ("energy_card_id") REFERENCES "card" ("card_id");
ALTER TABLE "pokemon_card" ADD FOREIGN KEY ("pokemon_pokedex_number") REFERENCES "pokemon_species" ("species_pokedex_number");
ALTER TABLE "pokemon_card" ADD FOREIGN KEY ("pokemon_pokedex_entry_id") REFERENCES "pokedex_entry" ("entry_id");
ALTER TABLE "pokemon_card" ADD FOREIGN KEY ("pokemon_sub_type_id") REFERENCES "pokemon_sub_type" ("pokemon_sub_type_id");
ALTER TABLE "pokemon_card" ADD FOREIGN KEY ("energy_type_id") REFERENCES "energy_type" ("energy_type_id");
ALTER TABLE "pokemon_ability" ADD FOREIGN KEY ("ability_type_id") REFERENCES "ability_type" ("ability_type_id");
ALTER TABLE "pokemon_ability" ADD FOREIGN KEY ("ability_pokemon_card_id") REFERENCES "pokemon_card" ("pokemon_card_id");
ALTER TABLE "pokemon_attack_link" ADD FOREIGN KEY ("link_pokemon_card_id") REFERENCES "pokemon_card" ("pokemon_card_id");
ALTER TABLE "pokemon_attack_link" ADD FOREIGN KEY ("link_attack_name_id") REFERENCES "attack_name" ("attack_name_id");
ALTER TABLE "attack_energy_cost" ADD FOREIGN KEY ("cost_link_id") REFERENCES "pokemon_attack_link" ("link_id");
ALTER TABLE "attack_energy_cost" ADD FOREIGN KEY ("cost_energy_type_id") REFERENCES "energy_type" ("energy_type_id");
ALTER TABLE "pokemon_attribute" ADD FOREIGN KEY ("attribute_pokemon_card_id") REFERENCES "pokemon_card" ("pokemon_card_id");
ALTER TABLE "pokemon_attribute" ADD FOREIGN KEY ("attribute_energy_type_id") REFERENCES "energy_type" ("energy_type_id");
ALTER TABLE "trainer_card" ADD FOREIGN KEY ("trainer_printed_type_id") REFERENCES "trainer_printed_type" ("trainer_printed_type_id");
ALTER TABLE "trainer_mechanic_link" ADD FOREIGN KEY ("mechanic_link_trainer_card_id") REFERENCES "trainer_card" ("trainer_card_id");
ALTER TABLE "trainer_mechanic_link" ADD FOREIGN KEY ("mechanic_link_game_mechanic_id") REFERENCES "game_mechanic" ("game_mechanic_id");
ALTER TABLE "energy_card" ADD FOREIGN KEY ("energy_main_type_id") REFERENCES "energy_type" ("energy_type_id");
+4
View File
@@ -0,0 +1,4 @@
# Лабораторная работа №2
* **Студент:** Закиров Алим Альбертович
* **Вариант / Карточка:** Наполнение базы данных и базовые SQL-запросы (INSERT, SELECT)
+191
View File
@@ -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, check: `pokemon_hp > 0`]
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]
ability_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