modeling complex data with sqlalchemy

Littlefield, Tyler tyler at tysdomain.com
Sat Aug 25 16:47:35 EDT 2012


Hello all:
I had a quick question.
In my game, I have an is-a setup, where all objects contain data like an 
id for sqlalchemy, a name, a description and a list of contents.
In order to add functionality to an object, you add components. So for 
example, a player would have the Player and Living component associated 
with the basic object. It's sort of a way to give myself a way to add 
functionality without having a lot of multiple inheritance.
This creates a problem for me though, since it looks like each component 
would have it's own table. How would you go about modeling the 1:n 
relationship between entity and each component?
Also, I'm going to have a location property on the object, which is 
basically it's location (a reference to another Entity), or None if it 
has no parent. How would you set that up in SA so that location gets 
translated to an ID and then translated back to the required object?
Might there be another easier way to model all this data? It looks like 
this database could get rather large, extremely quickly.

-- 
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.




More information about the Python-list mailing list