Quote:
Originally Posted by buggabill
Why?
Just delete the row that you need to delete, or add a new row to the table. The item_id column is the important one.
|
Maybe I wasn't clear enough. What I meant is that the items are all categorized, all cannons share the same properties while all engines also share the same properties. If the developers decide to add a new property to a cannon, they are also adding it to all the others. Now think about the database, suppose I have 30 cannons stored there, if I need a new property then I have to insert 30 new records in the properties database, one for each cannon. In my design all I would need is a new column in the cannons table, and then of course I'd need to set the value of this column for the 30 records.
Quote:
Originally Posted by buggabill
It does not matter what order the properties are in the table
|
Yes, for me the order does matter. I'm not just going to output the data to the page in whatever order they came from the query. The profile page for an item will have images and the properties will be displayed in special locations, some may be clickable, others may have a different CSS class and so on.
Also, think about the OOP part of the project. If I do it how you say then I'll have some trouble to load the data into the objects. I would have to load each property one by one:
Code:
damage = SELECT value FROM properties WHERE name = "damage" AND item_id = XXX;
cadence = SELECT value FROM properties WHERE name = "cadence" AND item_id = XXX;
OR I could query only once and then use a switch:
Code:
SELECT name, value FROM properties WHERE item_id = XXX;
foreach(record in result) {
switch(name) {
case "damage":
damage = value;
case "cadence":
cadence = value;
}
}
Don't get me wrong, I really liked your suggestion, it shows a different implementation that solves the problem and it made me think about other parts of the project and about my own implementation too. I haven't decided how I'm gonna do it yet, but right now it seems that your way is gonna bring me some trouble in the OOP field.
