Marauroa Database Structure: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>Hendrik Brummermann
imported>Kymara
m The whole picture: close brackets
 
(62 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Navigation for Marauroa Top}}
{{Navigation for Marauroa Top|Internals}}
{{Navigation for Marauroa Developers}}
{{Navigation for Marauroa Developers}}


{{Database Access}}
__TOC__



This article describes the table structure of the Marauroa database. You might want to have a look at [[High Level Database Access]] which explains the high level API to access the database from your program code. The article [[Low Level Database Access]] describes how Marauroa accesses the database internally and how you can add support for your own tables.
This article describes the table structure of the Marauroa database. You might want to have a look at [[High Level Database Access]] which explains the high level API to access the database from your program code. The article [[Low Level Database Access]] describes how Marauroa accesses the database internally and how you can add support for your own tables.
Line 19: Line 24:
[[Image:Database-account-bans.png‎]]
[[Image:Database-account-bans.png‎]]


Unfortunately there are some unfriendly people out there that you may need to keep away. The tables accountban and banlist store such bans.
== RPObjects ==
[[Image:Database-rpobjects.png‎]]


The table accountban is on a per account basis. The person trying to login is displayed the reason. Account bans can expire automatically.
== Game Logging ==
[[Image:Database-gamelog.png‎]]


The table banlist stores bans based on ip-address and ip-address-ranges. The mask 255.255.255.255 donates a single ip-address.
== The whole picture ==
[[Image:Database-marauroa.png‎]]


== Other stuff ==
== RPObjects ==
[[Image:Database-rpobjects.png‎]]


Marauroa knows two types of objects which can be stored to the database: players and zones. Both objects can contain other objects: Players have items in their bags, zones can contain objects that are flagged as storable.
{{Move everything below these lines into the [[Database Access]] article}}


Player objects are linked to their account using the table characters.
=== JDBC Database HOWTO===
{{TODO|Update to reflect DAOs}}
{{TODO|Add H2}}
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 relational databases. Unfortunatally it does not hide vendor specific stuff. Marauroa and Stendhal currently only work with MySQL because of that. Adding support for other database software would be very easy as the database specific code is concentrated in the classes JDBCDatabase (Marauroa) and StendhalPlayerDatabase (Stendhal). We have no need for that, so it was not done, yet. We will, however, accept patches for multi database system support, so if you need it, go ahead.


Note: Currently the rpobjects (including owned slots and rpojbects in those slots) are serialized in a Blob field. In the Marauroa Version 1.x it was a relational. Unfortunately that approach was failing performance requirements (MySQL is extremely slow on delete statements). There is a [[Meta object model for relational data storage|concept]] in development that proposes an improved relational structure.


== Game Logging ==
You need to download MySQL Connector/J in order to get it to run: http://www.mysql.com/downloads/api-jdbc-stable.html
[[Image:Database-gamelog.png‎]]


There are two more tables used for logging:
To configure Marauroa to work with a JDBC source, run the appropriate GenerateINI program. For Stendhal this is games.stendhal.server.core.engine.GenerateINI.


gameEvents stores events that occur in the game world (killing monsters, trading, teleporting, etc.) with a time stamp and the player causing the event. The parameters param1 and param2 depend on the event.
Before using the application with the database, you need to create the database itself. So, with MySQL just run MySQL and enter:
<pre>
create database stendhal;
grant all on stendhal.* to stendhal_user@localhost identified by 'stendhal_passwd';
</pre>


Unless disabled Marauroa logs statistical information every minute in the table statistics. This includes the network traffic data and number of players online.
The rest of code is handled by the server itself, and it will create the tables if they don't exist.


== The whole picture ==
=== Storing objects in the database ===
Objects are stored in the database to save their state. This is an expensive operation, so it is only done every 10 minutes or on special events (like logout).


The following diagram shows the all tables used by Marauroa. Games are, however, free to add their own tables if the need arises (JMapacman and Marboard don't need additional tables but Stendhal makes heavy use of [[Stendhal Database Structure|this possibility]].)
This decision is made in RPManager. It calculates how often an object has to be stored.


[[Image:Database-marauroa.png‎]]
Marauroa knows two types of objects which can be stored to the database: players and zones. Both objects can contain other objects: Players have items in their bags, zones can contain objects that are flagged as storable.




[[Category:Marauroa]]
[[Category:Marauroa]]
{{#breadcrumbs: [[Marauroa]] | [[Navigation for Marauroa Developers|Internals]] | [[Marauroa Database Structure|Database Structure]] }}