generated from admin/template
изменение с изучением lesson1
но не до конца следующее требованиям... V Все таблицы названы в единственном числе, а поля имеют префиксы своих таблиц? V В ячейках таблиц отсутствуют списки или массивы значений (данные атомарны)? V Связь между card и attack реализована через промежуточную таблицу card_attack? X Комбинированная стоимость атак вынесена в связующую таблицу attack_energy_cost с полем energy_quantity? (не полностью понял как это, надо изучить правила самой игры...) V Все связи Ref: явно заданы и ссылаются на существующие первичные ключи PK?
This commit is contained in:
+50
-32
@@ -1,49 +1,67 @@
|
||||
Table card {
|
||||
card_id int [primary key]
|
||||
pokemon_id int
|
||||
card_description text // у карт того же покемона бывают разные описания
|
||||
card_id int [pk]
|
||||
pokemon_id int [not null]
|
||||
card_description text [not null] // у карт того же покемона бывают разные описания
|
||||
|
||||
// данные, не влияющие на игру
|
||||
card_rarity int
|
||||
card_year int
|
||||
card_set_no int
|
||||
artist_id int
|
||||
card_rarity int // зависит от того, какими будут сами данные. скорее всего если Common => card_rarity == 0
|
||||
card_year int [not null]
|
||||
card_set_no int [not null]
|
||||
illustrator_id int [not null]
|
||||
|
||||
// игровые данные
|
||||
card_hp int
|
||||
attack_id int
|
||||
card_retreat_cost int
|
||||
card_hp int [check: `hp >= 0`]
|
||||
card_attack_id int [not null]
|
||||
card_retreat_cost int // может быть и нулевым
|
||||
}
|
||||
|
||||
Table pokemon {
|
||||
pokemon_id int [primary key]
|
||||
pokemon_name text
|
||||
pokemon_height_m numeric
|
||||
pokemon_weight_kg numeric
|
||||
pokemon_stage int
|
||||
|
||||
pokemon_resistance_element text
|
||||
pokemon_resistance_amount text
|
||||
pokemon_weakness_element text
|
||||
pokemon_weakness_amount text
|
||||
pokemon_id int [pk]
|
||||
pokemon_name text [not null]
|
||||
pokemon_height_m numeric [not null]
|
||||
pokemon_weight_kg numeric [not null]
|
||||
pokemon_stage int // опять же, зависит от самих данных. если Base, то pokemon_stage == 0
|
||||
}
|
||||
|
||||
Table artist {
|
||||
artist_id int [primary key]
|
||||
artist_name text
|
||||
Table illustrator {
|
||||
illustrator_id int [pk]
|
||||
illustrator_name text [not null]
|
||||
}
|
||||
|
||||
Table attack {
|
||||
attack_id int [primary key]
|
||||
attack_name text
|
||||
attack_description text
|
||||
attack_element text
|
||||
attack_energy_cost int
|
||||
attack_damage int
|
||||
attack_id int [pk]
|
||||
attack_name text [not null]
|
||||
attack_description text [not null]
|
||||
attack_element text [not null] // normal, fire, water, fighting, т.д.
|
||||
attack_energy_cost int // с нулевой энергией атаки бывают
|
||||
attack_damage int // бывают и атаки, направленные только на снижение какого-либо стата противника, не наносящие урон
|
||||
}
|
||||
|
||||
Ref: "pokemon"."pokemon_id" ?> "card"."pokemon_id"
|
||||
Table card_attack {
|
||||
card_attack_id int [pk]
|
||||
card_id int [not null]
|
||||
attack_id int [not null]
|
||||
|
||||
Ref: "artist"."artist_id" ?> "card"."artist_id"
|
||||
// «Почему связующая таблица card_attack необходима для хранения атак, а не запись attack_id напрямую в таблицу card?»
|
||||
// для добавления модификаторов к уже существующим данным
|
||||
pokemon_weakness_element text // fighting
|
||||
pokemon_weakness_amount text // x2
|
||||
pokemon_resistance_element text // normal
|
||||
pokemon_resistance_amount text // -20
|
||||
attack_damage_result int // урон, после того, как его прогнали через модификаторы
|
||||
}
|
||||
|
||||
Ref: "card"."attack_id" ?> "attack"."attack_id"
|
||||
Table attack_energy_cost {
|
||||
energy_cost_id int [pk]
|
||||
attack_id int [not null]
|
||||
energy_quantity int [check: `energy >= 0`]
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ref: "card"."pokemon_id" ?> "pokemon"."pokemon_id"
|
||||
Ref: "card"."illustrator_id" ?> "illustrator"."illustrator_id"
|
||||
Ref: "card"."card_attack_id" ?> "card_attack"."card_attack_id"
|
||||
Ref: "card_attack"."card_id" ?> "card"."card_id"
|
||||
Ref: "card_attack"."attack_id" ?> "attack"."attack_id"
|
||||
Ref: "attack_energy_cost"."attack_id" ?> "attack"."attack_id"
|
||||
Reference in New Issue
Block a user