01-29-2008, 03:57 AM
|
#5 (permalink)
|
|
The Contributor
Join Date: Jan 2008
Location: Brazil
Posts: 77
Thanks: 14
|
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).
|
|
|