I have to store various kinds of same return. The Worthiness can represent DATE, INT, BOOLEAN, DOUBLE and any other kind. I am wondering if it's possible not using multiple tables - each for various type (I guess it would considerably complicate use of saved Values (mainly searching, blocking)). Will it be a large storage and gratifaction degradation when storing multiple column table with mainly NULL values consecutively?
I am considering table with your example posts that just one value column is going to be filled:
id valueVarchar valueDate valueBoolean valueInt valueDouble
In the event that approach is clearly wrong please enlighten me.
I am creating JSF application using MySQL (InnoDB) (database isn't a large problem, it may be transformed if required) and JPA.
For now I've one table with one text value area. I am transforming values to/from database on server side. Since the project just lately been began and altering model now is going to be less painful than later on, I am thinking about information on better approach.
If you work with EclipseLink, use a @TypeConverter to transform data-type to String. You might have two column one for that value and something for that value's type, you can map this utilizing an @Transformation mapping.
With generic JPA you can transform the kind through get/set techniques using property access.
You are able to store anything like a binary value, and cast towards the type at client side. However the value can hardly be effectively used within query conditions.
In the comments, it seems that it's intended that for every entity, each attribute may have its value saved individually.
There's a reputation for this: it's known as the Entity-Attribute-Value model, or EAV for brief.
Although you will find situations by which EAV may be the only relevant solution, its me is generally regarded as being an anti-pattern where viable options can be found.
A example of the inappropriate implementation of the EAV database are available here.
Probably the most apparent reasons that EAV may be used is perfect for the persistence of Object data from OO designs, in relational databases. If this sounds like how you need to utilize it, I urge you to definitely consider Object-Relational Mapping (ORM for brief) rather.
You'll find EAV-related questions about SO while using eav tag.