I am trying to make a simple item database using MySQL for a game. Here is what my 3 tables would look like
items itemId | itemName --------------
I think having the data_type
column just further complicates the design. Why not simply have type
and description
be columns on the items
table? It stands to reason that every item would have each of those values, and if it doesn't then a null
would do just fine in a text column.
You can even further normalize the type
by having an item_types
table and the type
column in items
would be a numeric foreign key to that table. Might not be necessary, but might make it easier to key off of the type on the items
table.
Edit: Thinking about this further, it seems like you may be trying to have your data tables match a domain model. Your items would have a series of attributes on them in the logic of the application. This is fine. Keep in mind that your application logic and your database persistence layout can be different. In fact, they should not rely on each other at all at a design level. In many small applications they will likely be the same. But there are exceptions. Code (presumably object-oriented, but not necessarily) and relational data have different designs and different limitations. De-coupling them from one another allows the developer to take advantage of their designs rather than be hindered by their limitations.