You are viewing...

Starting to see why an Entity table could be useful.

Updated on February 24, 2013 at the 21th hour
Posted under:

DISCLAIMER: Expressed views on this blog are my own.

I've been discovering ways to manage data/resources in my database for Dark Gale and one way I found was to manage resource states, locks, and actions. Resource States are basically a link to a resource (Account, Notification, Mail, Magic, Item, etc.) and I attached two states (new, hidden) to this resource state to avoid lookups for checking if a resource is new or hidden especially since the table is so light weight. Locks work exactly how it is supposed to where it maintains a lock on an artificial resource where we have the expires time in unix time. Example for this is for player magic where we need a recharge lock and a magic cast lock because you don't want the player to cast magic for a certain amount of time and in the case of a magic cast lock, you don't want magic to stack up on a player. Obviously, if you do want it to stack, then don't set that lock. :) Actions are simply log entries, so it is a little heavier weight table because it stores the actionName and some metadata. Heavyweight data is pushed off to the general system log table. These are a apart of the Excerion PHP Library, though locks are a fairly new addition, so it might not be there yet.

An Entity System involves having an entity table. An entity table simply stores all of the entity ids. These ids have the properties that they are auto-generated and unique. They identify a specific entity in the system, which could be anything. If you have an entity id, then all you do is search that entity table to see if it exists. Now the application for this is for distributed systems where you are looking for data and you contact the many servers' entity table for what you are looking for.

It would be sweet to have an entity id associated with Actions, Resource States, Accounts, and etc., so you can look for what you want in one place and associate things with that one entity for flexibility, sort of like an Entity Component System (ECS). I'm not completely sure what defines an ECS, so maybe this is all wishful thinking and I created a variant of an ECS already. Anyway, it would be nice to just be able to query many servers with the entity you are looking for if the original server you were assigned to doesn't have it or even be able to find what server/cluster the entity may be located. I'm just getting started with knowing what the ECS is, so this may already be done, but I've been thinking of maintaining a statistical data structure called a Bloom Filter on entity ids, so that it would near constant time access to looking for whether an entity id exists in the server instead of doing a query for one of those guys, which takes time even if it doesn't exist. It seems that Google BigTable already does something like this with a Bloom Filter according to the Wikipedia page on Bloom Filters, so it may be possible for me to do this.
You just read "Starting to see why an Entity table could be useful.". Please share if you liked it!
You can read more recent posts here.