Answer the question
In order to leave comments, you need to log in
EAV or Create table for fixed sets of attribute values?
I welcome everyone.
For the database of the universal, boxed script of the online store, the Flat table pattern was chosen. Those. product values will not be stored in one EAV table, but a table will be created for each product type.
There will be many values in type tables that are better separated somewhere into "fixed sets of values". Those. e.g. "color", "texture", "material". Writing a million times in each entry "red", "yellow", ... "plastic" ... - that's what you need to get rid of. Instead, there will naturally be id values. And here, again, we come to EAV vs Create table =)))
So, you need to decide where to store "fixed sets of values", like color values, material values. In one table? Or for each attribute to create under the table?
1.EAV. The idea is that he asks here. Indeed, we are advised EAV, when the number of attributes is large, and the number of records is not large. If to do tables - that they will contain few records. The disadvantages of EAV, I think, are well known - this is the speed, and the complexity of 3-storey queries. But... For me, as for a person who studied mathematics, EAV, first of all, is not attractive because it distorts the most basic ideology of RDB - relation, "relationships". All subsequent construction will be "torn off" from mathematics. I'm not a fan) and also for practical solutions) Just my purely individual opinion, EAV is appropriate: If 1) Attributes are very dynamic (every few hours and even every 10 minutes, they change/add/remove) AND THIS IS 2) Number - in the records of the tables (whose structure changes) is very large (> 1 million records). If these conditions are met at the same time, there is simply no way without EAV. Each change (ALTER TABLE) will lock the database, and will take a very long time to complete.
2.Flate table. As far as I understand, directly the number of tables in the database does not significantly affect the speed. There is only a question of convenience. But after all, nothing prevents tables from sticking the prefix "z_" / "zz_" and all of them will be displayed at the end of the database. Although there are a thousand of them - they grow down the database and that's all. And their names are set according to the strict format "zz_"."type_value_"."{atribute_name}"
In general, I want to hear your opinions, ANY reasoning is welcome =)))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question