I'm trying to decide how to store some data in my database. (SQLite) Let's say we have 2 tables : Attribute and Type
Table Type is more or less like an enum, it stores all types existing in my model (Integer, Real, Alphanumeric for example)
Table Attribute contains attributes, a record looks like this :
Attribute :
id : its id
name : name of the attribute
value : ??? (the main question here)
type : foreign key to table type
So an attribute can be of type Integer, Real or alphanumeric. I'm not sure how to proceed to store the value of the attribute depending on the type.
I've considered so far 3 solutions :
Solution 1 : The "value" field of attribute is of type String and I convert in the relevant type programmaticaly
Solution 2 : I create more "value" field like : intValue, realValue, and alphanValue, and put NULL in irrelevant fields depending on the type
Solution 3 : I create 3 more tables, IntValue, RealValue and AlphaNValue with foreign key to the related Attribute.
I want to know which solution is better in terms of performance and consistency, or if there's another relevant solution I haven't been thinking of.
Thanks a lot