Skip to content

Game database model

Store all SQL statements that create your custom tables in dbmodel.sql at the root of your project folder. This file is executed before each new game table is set up.

General rules

  • Keep things simple. Games usually have a small number of pieces, so your database will remain small and fast.
  • Do not store translatable strings in the database. Store a code instead, and replace it with the corresponding translatable string in PHP.
  • Create a Manager class for each table. Only this class should execute SQL statements for that table.
  • Store only dynamic data in the database. Store all static data in PHP files, in the associated Manager class.

dbmodel.sql file

If you use libraries such as ItemManager, PlayerCounter and TableCounter, you may not need to create SQL tables manually. You can delete dbmodel.sql if you don't need any custom tables.

Default tables

By default, BGA creates default tables for your game: player, global, stats, gamelog and tables prefixed with bga_.

BGA internal tables

You MUST NOT MODIFY the schemas of these tables.

To read or write values in these tables, use the appropriate framework API. DO NOT query them directly in the game code.

You can inspect their values using the Go to game database button or the debug buttons for counters and globals.