diff --git a/lesson2.sql b/lesson2.sql index 4b8edd6..280f7d5 100644 --- a/lesson2.sql +++ b/lesson2.sql @@ -1,40 +1,55 @@ -Table illustrator { - illustrator_id int [pk, increment, unique, note: 'CHECK (illustrator_id > 0)'] - illustrator_name text [not null, unique] -} - -Table element_type { - element_type_id int [pk, increment, unique, note: 'CHECK (element_type_id > 0)'] - element_type_name text [not null, unique] -} - -Table card_set { - set_id int [pk, increment, unique, note: 'CHECK (set_id > 0)'] - set_name text [not null, unique] - set_code text [not null, unique] - set_total_cards int [not null, note: 'CHECK (set_total_cards > 0)'] -} - -Table card { - card_id int [pk, increment, unique, note: 'CHECK (card_id > 0)'] - card_name text [not null] +create table card ( + card_id int [primary key] + card_name text [not null, unique] card_hp int [not null] - card_number text [not null, note: 'CHECK (card_number > 0)'] - card_illustrator_id int [not null] - card_element_type_id int [not null] card_set_id int [not null] -} + card_illustrator_id int [not null] +); -Table attack { - attack_id int [pk, increment, note: 'CHECK (attack_id > 0)'] +create table illustrator ( + illustrator_id int [primary key] + illustrator_name text [not null] +); + +create table card_set ( + card_set_id int [primary key] + card_set_name text [not null, unique] + card_set_code text [not null, unique] + card_set_release_date date [not null] +); + +create table card_attack ( + card_attack_id int [primary key] + card_id int [not null] + attack_id int [not null] +); + +create table attack ( + attack_id int [primary key] attack_name text [not null] - attack_base_damage int [not null, note: 'CHECK (attack_base_damage >= 0)'] - attack_damage_modifier text [note: 'CHECK (attack_damage_modifier in ["+", "x"])'] - attack_card_id int [not null] -} + attack_base_damage int [not null] +); -Ref: "card"."card_illustrator_id" ?> "illustrator"."illustrator_id" +create table element_type ( + element_id int [primary key] + element_name text [not null, unique] +); -Ref: "card"."card_set_id" ?> "card_set"."set_id" +create table attack_energy_cost ( + attack_energy_cost_id int [primary key] + attack_id int [not null] + element_type_id int [not null] + energy_quantity int [not null] +); -Ref: "card"."card_element_type_id" ?> "element_type"."element_type_id" \ No newline at end of file +Ref: "card"."card_illustrator_id" > "illustrator"."illustrator_id" + +Ref: "card"."card_set_id" ?> "card_set"."card_set_id" + +Ref: "card_attack"."card_id" > "card"."card_id" + +Ref: "attack"."attack_id" "element_type"."element_id" \ No newline at end of file