Ejemplo n.º 1
0
    public void BuildDBSchema()
    {
        Debug.Log("Start constructing DB");

        db = GetComponent <dbAccess>();
        db.OpenDB("VBBS.db");

        // Create Table for Match
        string[] match = new string[] {
            "ID INTEGER PRIMARY KEY AUTOINCREMENT",
            "date TEXT",
            "time TEXT",
            "location TEXT",
            "name TEXT",
            "team TEXT",
            "enemy TEXT",
            "matchStyle INTEGER",
            "ruleStyle INTEGER",
        };

        db.CreateTableByQuery("matches", match);

        // Create Table for Round
        string[] round = new string[] {
            "ID INTEGER PRIMARY KEY AUTOINCREMENT",
            "team_score INTEGER",
            "enemy_score INTEGER",
            "match_ID INTEGER",
            "FOREIGN KEY(match_ID) REFERENCES matches(ID)"
        };

        db.CreateTableByQuery("rounds", round);

        // Create Table for Each Ball

        string[] ball = new string[] {
            "ID INTEGER PRIMARY KEY AUTOINCREMENT",
            "time NUMERIC",
            "start_X NUMERIC",
            "start_Y NUMERIC",
            "end_X NUMERIC",
            "end_Y NUMERIC",
            "attacker INTEGER",
            "team_player INTEGER",
            "enemy_player INTEGER",
            "skill INTEGER",
            "good INTEGER",
            "score INTEGER",
            "score_reason INTEGER",
            "team_change INTEGER",
            "team_switch INTEGER",
            "team_position INTEGER",
            "team_score INTEGER",
            "enemy_score INTEGER",
            "enemy_change INTEGER",
            "enemy_switch INTEGER",
            "enemy_position INTEGER",
            "round_ID INTEGER",
            "FOREIGN KEY(round_ID) REFERENCES rounds(ID)"
        };

        db.CreateTableByQuery("balls", ball);

        Debug.Log("Constructing Done");

        db.CloseDB();
    }