Course: CSCI 2020

Initial Design

WARNING

This potentially will change as we develop our ideas more, but it’s more of a rough outline of what the database will include.

Preliminary ERD

erDiagram
    POCKETMON {
        int id PK
        string name
        int base_hp
        int base_attack
        int base_defense
        int base_speed
        int base_special_attack
        int base_special_defense
    }
    
    TYPE {
        int id PK
        string name
    }
    
    ABILITY {
        int id PK
        string name
        string effect
    }
    
    MOVE {
        int id PK
        string name
        int power
        int accuracy
        int pp
        string category
        int type_id FK
    }
    
    POCKETMON_TYPE {
        int pocketmon_id FK
        int type_id FK
    }
    
    POCKETMON_ABILITY {
        int pocketmon_id FK
        int ability_id FK
    }
    
    POCKETMON_MOVE {
        int pocketmon_id FK
        int move_id FK
        string method
    }
    
    POCKETMON ||--o{ POCKETMON_TYPE : has
    TYPE ||--o{ POCKETMON_TYPE : categorized_as
    
    POCKETMON ||--o{ POCKETMON_ABILITY : has
    ABILITY ||--o{ POCKETMON_ABILITY : grants
    
    POCKETMON ||--o{ POCKETMON_MOVE : learns
    MOVE ||--o{ POCKETMON_MOVE : associated_with
    
    TYPE ||--o{ MOVE : determines

Relationship Mappings & Cardinality

Entity ARelationshipEntity BCardinalityDescription
POCKETMONhasPOCKETMON_TYPE1 to manyA Pocketmon can have one or two types
POCKETMON_TYPEcategorized asTYPEmany to 1A type can be assigned to many Pocketmon
POCKETMON_ABILITYgrantsABILITYmany to 1An ability can belong to multiple Pocketmon
POCKETMONlearnsPOCKETMON_MOVE1 to manyA Pocketmon can learn many moves
POCKETMON_MOVEassociated withMOVEmany to 1A move can be learned by many Pocketmon
MOVEdeterminesTYPEmany to 1Each move belongs to a single type

Attribute Lists

  • POCKETMON
    • id → primary key
    • name → unique, name of the Pocketmon
    • base_hp → HP stat
    • base_attack → attack stat
    • base_defense → defense stat
    • base_speed → speed stat
    • base_special_attack → special attack stat
    • base_special_defense → special defense stat
  • TYPE
    • id → primary key
    • name → unique, such as ‘fire’ or ‘water’
  • ABILITY
    • id → primary key
    • name → unique, such as ‘intimidate’
    • effect → the effect of the ability, such as lowering the opponents attack
  • MOVE
    • id → primary key
    • name → unique, such as ‘flamethrower’
    • power → move base power, nullable for status moves
    • accuracy → percentage of the move accuracy
    • pp → number of times the move can be used
    • category → category of the move, ‘physical’, ‘special’, or ‘status’
  • POCKETMON_TYPE
    • pocketmon_id → foreign key → POKEMON.id
    • type_id → foreign key → TYPE.id
  • POCKETMON_ABILITY
    • pocketmon_id → foreign key → POKEMON.id
    • ability_id → foreign key → ABILITY.id
  • POCKETMON_MOVE
    • pocketmon_id → foreign key → POKEMON.id
    • move_id → foreign key → MOVE.id
    • method → how the move is learned, such as level-up or TM

Primary & Key Strategies

TablePrimary KeyForeign Keys
POCKETMONid (PK)
TYPEid (PK)
ABILITYid (PK)
MOVEid (PK)type_idTYPE.id
POCKETMON_TYPE(pocketmon_id, type_id) (composite PK)pocketmon_idPOCKETMON.id
type_idTYPE.id
POCKETMON_ABILITY(pocketmon_id, ability_id) (composite PK)pocketmon_idPOCKETMON.id
ability_idABILITY.id
POCKETMON_MOVE(pocketmon_id, move_id) (composite PK)pocketmon_idPOCKETMON.id
move_idMOVE.id