View Single Post
Old 01-29-2008, 03:57 AM   #5 (permalink)
DeMo
The Contributor
 
DeMo's Avatar
 
Join Date: Jan 2008
Location: Brazil
Posts: 77
Thanks: 14
DeMo is on a distinguished road
Default

Hey guys, thanks for your suggestions!

I think what Alan said is very close to what I outlined in my solution 3 with the exception that I would put some standard data (like item name and price) in what he called the index-table.

buggabill and ReSpawN, your approach is interesting too but I don't really like the idea of having the data all scattered like that. As buggabill said, if I need to add/remove a property in my design I'd have to add/remove a column to the table and change all my querys, but in your design if I have 30 items and I wanna add/remove a property I also have to insert/delete 30 rows.

Besides that, I was thinking of using an OOP approach for this project, something along these lines:
PHP Code:
class BasicItem {
    public 
$id
    
public $type
    
public $name
    
public $size
    
public $price
}

class 
Weapon extends BasicItem {
    public 
$damage
    
public $cadence
}
/* Please ignore the public scope, it's just an example */ 
Now if I want to load some data from the DB into a Weapon object I guess it's better if I have a "weapons" table with the columns "damage" and "cadence" (and the "id" of course).
Send a message via ICQ to DeMo Send a message via MSN to DeMo Send a message via Skype™ to DeMo
DeMo is offline  
Reply With Quote