What is the best way to store categorical references in SQL tables?

Posted by jlafay on Stack Overflow See other posts from Stack Overflow or by jlafay
Published on 2010-06-05T20:33:16Z Indexed on 2010/06/05 20:42 UTC
Read the original article Hit count: 209

Filed under:
|
|
|
|

I'm wanting to store a wide array of categorical data in MySQL database tables. Let's say that for instance I want to to information on "widgets" and want to categorize attributes in certain ways, i.e. shape category.

For instance, the widgets could be classified as: round, square, triangular, spherical, etc. Should these categories be stored within a table to reference them best from an application? Another possibility, I would imagine, would be to add a column to widgets that contained a shape column that contained a tiny int. That way my application could search shapes by that and then use a coordinating enum type that would map the shape int meanings.

Which would be best? Or is there another solution that I'm not thinking of yet?

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql