Answer the question
In order to leave comments, you need to log in
How to make virtual columns in ActiveRecord?
The thing is elementary. There is a table of products with a fixed set of columns, such as name and price.
These characteristics are present in all products. And there is, for example, color and size, or, even worse, some unique feature inherent only in certain products.
Different price lists will be loaded into the system, each of which will look like with a different set of fields, etc.
It is supposed to make the following structure
Product [id, brand, name, price]
Field [id, name, order]
Value [id, value]
Data [id, product_id, field_id, value_id]
Answer the question
In order to leave comments, you need to log in
I think it can be simplified
Product [id, brand, name, price]
Field [id, name, order]
Data [id, product_id, field_id, value]
It all depends on what you will need to do with this data.
If it's just to store, then welcome to PostgreSQL and the json column type (at least write the hell out there).
If you need to search, then I would stay with PostgreSQL and hang ElasticSearch on top and search in it.
And all these EAVs are good only in the picture. When difficult requests begin - "floated".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question