Database tables for records of another table?

I am developing a new version of my Java application (using the embedded H2 database) around redesigning how I will handle my data. Here's how I planned:

  • Table entries
    • Record ID
    • Record name
  • Table properties
    • Property ID
    • Property name
  • (individual property) value table -
    • Value identifier
    • Record ID
    • (value columns ...)
  • (individual entry) value table -
    • Property name
    • (individual property) value ID

Each record can have multiple properties (including multiple properties of the same type). Each property has its own way of storing its values. I need to find all the properties defined for a given entry, and possibly all entries for each given property.

Is this a good way to do it?

Edit: I'm not sure I explained it well ...

0


a source to share


3 answers


In my opinion, this is a very bad way of modeling data, but it is a very elephant tower-like way of looking at the situation, since I did not have to use this model in practice. By the way, it's called the "Entity-Attribute-Value" approach. And the reason I don't like this is because it is very non-schema like most SQL functionality has to be replicated in some way.



There is definitely a time and place for it (for example if you are going to model many objects with disparate models) or that change frequently. But I personally find it terrible.

+3


a source


If you understand correctly, I would use an intersection or junction instead of what you described.



So, you can create a query to get all properties for each item, or all Enteries values ​​for each property.

+1


a source


I agree with Unknown Google. This is also called the In-Platform Effect .

0


a source







All Articles