diff --git a/shema b/shema new file mode 100644 index 0000000..f98cba0 --- /dev/null +++ b/shema @@ -0,0 +1,154 @@ +create table card_set ( + CARD_SET_NAME VARCHAR(255) not null, + CARD_SET_ID VARCHAR(20) PRIMARY key, + CARD_SET_SERIES VARCHAR(50) not null, + CARD_SET_TOTAL_CARDS inteGER not null, + CARD_SET_data date not null +); + +insert into card_set (CARD_SET_NAME, CARD_SET_ID, CARD_SET_SERIES, CARD_SET_TOTAL_CARDS, CARD_SET_data) values +('XY Базовый набор', 'XY1', 'XY', 146, '2014-02-05'), +('XY Огненная вспышка', 'XY2', 'XY', 106, '2014-05-07'), +('XY Яростный кулак', 'XY3', 'XY', 111, '2014-08-13'), +('XY Призрачные силы', 'XY4', 'XY', 119, '2014-11-05'), +('XY Первобытная дуэль', 'XY5', 'XY', 160, '2015-02-04'), +('XY Грохочущие небеса', 'XY6', 'XY', 108, '2015-05-06'), +('XY Древние истоки', 'XY7', 'XY', 98, '2015-08-12'), +('XY Прорыв', 'XY8', 'XY', 162, '2015-11-04'), +('XY Тайное превосходство', 'XY9', 'XY', 122, '2016-02-03'), +('XY Столкновение судеб', 'XY10', 'XY', 124, '2016-05-02'); + +create table card ( +card_id int primary key, +card_name VARCHAR(50) not null, +card_number VARCHAR(50) not null, +card_set_id int references card_set (card_set_id), +card_name text not null, +card_rarity text not null , +card_type text not null, +card_image_url text not null, +CONSTRAINT unique_set_number unique (card_set_id, card_number) +); + +create table pokemon_card ( +pokemon_card_id int primary key references card (card_id), +pokemon_pokedex_number int references pokemon_species (species_pokedex_number), +pokemon_pokedex_entry_id int references pokedex_entry (entry_id), +pokemon_hp int not null, +pokemon_stage text not null, +pokemon_evolves_from text not null, +pokemon_retreat_cost int not null check (pokemon_retreat_cost in (0, 4)), +pokemon_sub_type_id int references pokemon_sub_type (sub_type_id), +pokemon_category text not null, +pokemon_printed_height int not null, +pokemon_printed_weight int not null +); + +create table energy_type ( +energy_type_id int primary key, +energy_type_name text unique not null, +energy_type_icon_url text not null +); + +create table pokemon_sub_type ( +sub_type_id int primary key, +sub_type_name text unique not null, +sub_type_deafault_prize_count int not null, +sub_type_global_rule_text text not null +); + +create table ability_type ( +ability_type_id int primary key, +ability_type_name text unique +); + +create table attack_name ( +attack_name_id int primary key, +attack_name_title text unique not null +); + +create table trainer_printed_type ( +printed_type_id int primary key, +printed_type_name text unique not null +); + +create table game_mechanic ( +mechanic_id int primary key, +mechanic_name text unique not null +); + +create table pokemon_species ( +species_pokedex_number int primary key, +species_eng_game text unique not null, +species_generation int not null, +species_heigth_m float not null, +species_weigth_m float not null +); + +create table pokedex_entry ( +entry_id int primary key, +entry_pokedex_number int references pokemon_species (species_pokedex_number), +entry_source_game text not null, +entry_description text not null +); + +create table trainer_card ( +trainer_card_id int primary key references card (card_id), +trainer_printed_type_id int references trainer_printed_type (printed_type_id), +trainer_effect_text text not null, +trainer_is_ace_spec boolean not null +); + +create table energy_card ( +energy_card_id int primary key references card (card_id), +energy_is_special boolean not null, +energy_main_type_id int references energy_type (sub_type_id), +energy_effect_text text +); + +create table pokemon_ability ( +ability_pokemon_card_id int primary key references pokemon_card (pokemon_card_id), +ability_type_id int references ability_type (ability_type_id), +ability_name text not null, +ability_effect_text text not null +); + +create table pokemon_attack_link ( +link_id int primary key references attack_energy_cost (cost_id), +link_pokemon_card_id int references pokemon_card (pokemon_card_id), +link_attack_name_id int references attack_name (attack_name_id), +link_damage_value text not null, +link_effect_text text not null, +primary key (link_pokemon_card_id, link_attack_name_id) +); + +create table attack_energy_cost ( +cost_id int primary key, +cost_link_id int references pokemon_attack_link (link_id), +cost_energy_type_id int references energy_type (energy_type_id), +cost_quantity int not null +); + +create table pokemon_attribute ( +attribute_id int primary key, +attribute_pokemon_card_id int references pokemon_card (pokemon_card_id), +attribute_energy_type_id int references energy_type (energy_type_id), +attribute_kind text not null, +attribute_modifier_value text not null, +attribute_pokemon_card_id, attribute_energy_type_id, attribute_kind, +primary key (attribute_pokemon_card_id, attribute_energy_type_id, attribute_kind) +); + +create table trainer_mechanic_link ( +mechanic_link_trainer_card_id int references trainer_card (trainer_card_id), +mechanic_link_mechanic_id int not null, +primary key (mechanic_link_trainer_card_id, mechanic_link_mechanic_id), +foreign key (mechanic_link_trainer_card_id) references trainer(trainer_id), +foreign key (mechanic_link_mechanic_id) references game_mechanic(mechanic_id) +); + + + + + + diff --git a/лабы базы b/лабы базы deleted file mode 100644 index 366637c..0000000 --- a/лабы базы +++ /dev/null @@ -1,157 +0,0 @@ -create table card_set ( -set_id int primary key, -set_name text unique not null, -set_code text unique not null, -set_total_cards int not null, -set_realese_date date not null, -set_logo_url text not null, -set_symbol_url text not null, -); - -create table energy_type ( -energy_type_id int primary key, -energy_type_name text unique not null, -energy_type_icon_url text not null, -); - -create table pokemon_sub_type ( -sub_type_id int primary key, -sub_type_name text unique not null, -sub_type_deafault_prize_count int <= -sub_type_global_rule_text text not null -); - -create table ability_type ( -ability_type_id int primary key, -ability_type_name text unique in ("Hydro", "Pump", "Slash") -); - -create table attack_name ( -attack_name_id int primary key, -attack_name_title text unique not null, -); - -create table trainer_printed_type ( -printed_type_id int primary key, -printed_type_name text unique not null, -); - -create table game_mechanic ( -mechanic_id int primary key, -mechanic_name text unique not null, -); - -create table pokemon_species ( -species_pokedex_number int primary key, -species_eng_game text unique not null, -species_generation int not null, -species_heigth_m float not null, -species_weigth_m float not null, -); - -create table pokedex_entry ( -entry_id int primary key, -entry_pokedex_number int references pokemon_species (species_pokedex_number), -entry_source_game text not null, -entry_description text not null, -); - -create table card ( -card_id int primary key foreign key -card_number text not null, -card_set_id int int references card_set (card_set_id), -card_name text not null, -card_rarity text not null -card_type text in ("Pokemon", "Trainer", "Energy") -card_image_url text not null, -primary key (card_set_id, card_number) -); - -create table pokemon_card ( -pokemon_card_id int primary key references card (card_id), -pokemon_pokedex_number int references pokemon_species (species_pokedex_number), -pokemon_pokedex_entry_id int references pokedex_entry (entry_id), -pokemon_hp int not null, -pokemon_stage text not null in ("Basic", "S1", "Mega") -pokemon_evolves_from text not null, -pokemon_retreat_cost int not null check (pokemon_retreat_cost in (0, 4)) -pokemon_sub_type_id int references pokemon_sub_type (sub_type_id), -pokemon_category text not null -pokemon_printed_height int not null -pokemon_printed_weight int not null -); - -create table trainer_card ( -trainer_card_id int primary key references card (card_id) -trainer_printed_type_id int references trainer_printed_type (printed_type_id) -trainer_effect_text text not null -trainer_is_ace_spec boolean not null -); - -create table energy_card ( -energy_card_id int primary key references card (card_id) -energy_is_special boolean constraint if true check (energy_is_special in (0, 4)) -energy_main_type_id int references energy_type (sub_type_id) <= -energy_effect_text text <= -); - -create table pokemon_ability ( -ability_pokemon_card_id int primary key references pokemon_card (pokemon_card_id) -ability_type_id int references ability_type (ability_type_id) -ability_name text not null -ability_effect_text text not null -); - -create table pokemon_attack_link ( -link_id int primary key references attack_energy_cost (cost_id) -link_pokemon_card_id int references pokemon_card (pokemon_card_id) -link_attack_name_idreferences attack_name (attack_name_id) -link_damage_value text not null -link_effect_text text not null -primary key (link_pokemon_card_id, link_attack_name_id) -); - -create table attack_energy_cost ( -cost_id int primary key -cost_link_id int references pokemon_attack_link (link_id) -cost_energy_type_id int references energy_type (energy_type_id) -cost_quantity int not null -); - -create table pokemon_attribute ( -attribute_id int primary key -attribute_pokemon_card_id int references pokemon_card (pokemon_card_id) -attribute_energy_type_id int references energy_type (energy_type_id) -attribute_kind text in ("Weakness", "Resistance") -attribute_modifier_value text not null -attribute_pokemon_card_id, attribute_energy_type_id, attribute_kind -primary key (attribute_pokemon_card_id, attribute_energy_type_id, attribute_kind) -); - -create table trainer_mechanic_link ( -mechanic_link_trainer_card_id int references trainer_card (trainer_card_id) -mechanic_link_mechanic_id int references game_mechanic (mechanic_id) -primary key (mechanic_link_trainer_card_id, mechanic_link_mechanic_id) -); - - - - - - - - - - - - - - - - - - - - - -