Marauroa Database Structure

From Arianne
Revision as of 12:25, 5 February 2005 by imported>MiguelAngelBlanchLardin
Jump to navigation Jump to search

Basic idea behind Database storage

We use database to store game state so that the game becomes a true persisten game.

Database Tables and Relationships

The database table relationship schema is:

Table PLAYER
  {
  PK(username)
  password
  }

Table CHARACTERS
  {
  PK(character)
  content
  }

Table LOGIN_EVENT
  {
  PK(id)
  address
  timedate
  result
  }

Table STATISTICS
  (
  PK(timedate)

  bytes_send
  bytes_recv

  players_login
  players_logout
  players_timeout
  players_online
  )

Table RPOBJECT
  (
  PK(id)
  slot_id
  )

Table RPATTRIBUTE
  (
  PK(object_id)
  PK(name)
  value
  )

Table RPSLOT
  (
  object_id
  name
  PK(slot_id)
  )

Relationships:

Relationship PLAYER_CHARACTERS
  {
  PK(player_username)
  PK(characters_character)
  }

Relationship PLAYER_LOGIN_EVENT
  {
  PK(player_username)
  PK(login_event_id)
  }

Translate this to SQL easily and you have the SQL schema of Marauroa


JDBC Database HOWTO

JDBC technology is an API that lets you access virtually any tabular data source from the Java programming language. It provides cross-DBMS connectivity to a wide range of SQL databases, and now, with the new JDBC API, it also provides access to other tabular data sources, such as spreadsheets or flat files.

JDBCPlayerDatabase is anyway not database independent; on the Player table we are using AUTOINCREMENT that is a unique keyword of MySQL that is not part of the SQL standard.

You need to download MySQL Connector/J in order to get it to run.
http://www.mysql.com/downloads/api-jdbc-stable.html

To configure Marauroa to work with a JDBC source we need to modify the configuration of the JDBC Connection.

So open the configuration file marauroad.ini (or whatever you choose to name it) and edit the next fields

marauroa_DATABASE=JDBCPlayerDatabase

jdbc_class=com.mysql.jdbc.Driver
jdbc_url=jdbc:mysql://localhost/marauroa
jdbc_user=marauroa_dbuser
jdbc_pwd=marauroa_dbpwd
  • jdbc_class: This field tells the engine what Driver to use for database access. Please refer to your software manual to see the multiple options.
  • jdbc_url: This points to the type and source of the information, for MySQL the string must be as follows:
    • jdbc:mysql://ip:database_name/
  • jdbc_user: This is the username for the database
  • jdbc_pwd: This is the password for that username in the database.

Now, simply save the changes and your configuration file is ready.

Before using the application with the database, you need to create the database itself. So, with MySQL just run MySQL and enter:

create database marauroa;
grant all on marauroa.* to marauroa_dbuser@localhost identified by 'marauroa_dbpwd';

The rest of code is handled by the server itself, and it will create the tables if they don't exist.