What is the problem? I want to make a material database. The User should be able to create different material types and create materials of this type. But different material types have different material properties. And new materials may have new properties.
Example:
Material 1: Oil
- Viscosity
- Density
- Melting Point
Material 2: Metal
- Density
- Melting Point
- Ductility
Material 3: cement
- Finess of cement
- Soundness of cement
- Strength
- Setting time
- Heat of Hydration
Material X: xxxxx
You see that different materialtypes has sometimes same or different properties. Some materialtypes have few properties others many. The properties may be of complete different data types, like STRING, FLOAT, INT, etc.
Adding a new materialtype should not result in a "development of new code" and an admin to create / change the DB / Table Schema.
So I need an approach where an User can create a new material type in the application, can create new properties in the application and create the relationship between both, meaning he defines (=relationship) which properties a materialtype has.
When then creating material, he selects the material type of the material and fills out only the properties the material has.
Under the DB normalization rules, materialtype, properties and material would be 3 different tables. Also there would be relationtables which create the relations between the tables and the values of the properties.
What would be the best approach? My ideas:
1. EAV with all the problems associated, values are stored in STRING format, whatever they are
2. EAV with the difference, that in the Table for the main DATA Types like STRING, FLOAT, BOOLEAN, BLOB I will have a separate column, the Data Type column defines in which column the data will be stored
3. Each datatype will create a OWN Table (this customtable's name will be stored in a column/field of the Materialtype table). The created table will have fields/columns with the right datatype of each property [maybe many different tables]
Are there other options and what would you recommend?
Asked by Oliver R.
(1 rep)
Dec 23, 2024, 05:05 PM
Last activity: Dec 24, 2024, 12:51 PM
Last activity: Dec 24, 2024, 12:51 PM