Verileri saklama "dikey", yani bir Entity-Attribute-Value a> (EAV) biçiminde, EAV örtülü [meta] veri odaklı şema yönetimi ile birlikte, "her ürünün nitelikleridir bir çerçeve sağlamak birbirinden gelen "bağımsız. Bu da, matkap-aşağı uygulanmasını (her her tür olası değerleri öznitelik listesi için son kullanıcı, hala geçerli olası niteliklerinin listesi ile sağlanan adım sorgunun yani güdümlü arıtma,) kolaylaştırır.
Küçük bir uyarı EAV modeli büyük veritabanları ile bazı performans ve / veya ölçeklendirme sorunları tanıtmak için bu küçük katalogları (diyelim az 1 Milyon ürünleri) daha uygulanabilir olmasıdır. Bir endişe olduğu performans de gerçek boyutu katalog (ürün başına niteliklerin ortalama sayısı, farklı bir tip, "ontoloji" gibi genel karmaşıklık ürünler arasındaki niteliklerin ortaklığı) özelliklerine göre değişir, ama EAV oldukça olduğunu küçük katalogları gitmek için yol. Sadece mantıksal şema, "detaya" filtreleme için onun desteğine ek olarak o (yeteneği eklemek / fiziksel (veritabanı) şemasının bir değişiklik gerektirmeden, nitelikleri ve / veya ürün türleri, vb kaldırmak esnek veri şemasını tanıttı açıklanır ) değiştirdi.
Edit: more detail/resources on EAV
Admittedly, the Wikipedia article about it is somewhat abstract...
In a nutshell, the model identify the following concepts:
- Varlık (aka bir ürün, ya da bir öğe) geleneksel ilişkisel dil içinde bir "rekor" =
- Özellik RDBMS lingo bir "sütun" (aka "alan") =
- Değeri = belirli bir kaydın belirli bir sütun sayısal (veya dize veya başka türlü) bir değer.
- Tip (aka kategori) = RDBMS [gevşek], bir "masa", kayıtların yani bir dizi olan pay, genellikle, öznitelikler aynı set.
Bir elektronik eşya katalog, diyelim ki, bunu açıklamak için, bir işletmenin belirli bir "Düz Ekran Monitör" olabilir, onun Tipi "Görüntü Cihazları", onun Nitelikler "Boyut", "Çözüm", "Fiyat" vb olabilir
EAV ile, bilgileri ve toplu ürün iki tablo ki adı verilen tablolar ve ProductAttributes tabloda depolanır:
Product table
"ProductID" (primary key, the "EntityId")
"TypeId"
optionally, some common attributes found in all/most other Products, say...
price
ManufacturerId
Photo
ProductAttributes table
"ProductID" (Foreign Key to Product table)
"AttributeID" (FK to Attribute table)
"Value" (actual value; note: sometimes we can have several SQL fields for
this say IntValue, StringValue, DateValue, allowing to store
values in their natural format)
Yukarıdaki tablolar data kısmını oluşturmaktadır, ve aynı zamanda "meta" olarak bilinen katalog [mantıksal] şema, depolanması tablolar tarafından tamamlanmaktadır. Bu tablolar şunlardır:
- Nitelikler tanımlanmıştır tablo öznitelikleri: Adı, veri türü, IsRequired ve böyle.
- Türleri (kategoriler) tanımlanmıştır Türleri Tablo: Adı, hiyerarşik ontolojiler durumunda muhtemelen ebeveyn tipi.
- Verilen bir tür için olası nitelikler listelenir Type_Attributes (örn: "TV Set" nitelik "kanallarının sayısı" vardır, "Ekran Boyutu" gibi bir "VCR" özniteliği "Başkanları Sayısı" vardır, "Format desteklenen" , "Gövde rengi" vb
All this may seem somewhat complicated, compared with the traditional approach whereby the logical schema is "hardcoded" within the SQL schema, i.e. we have one "TVSets" Table with its set of columns one per attribute, and then a "VCR" table with its own, different set of columns/attributes. However with such an approach the application logic ends up hard-coding in some fashion (if only through an indirection in a map of sorts) the table and column names.
In contrast, the EAV model, allows the program to discover the list of possible types, and, for each type the list of possible attributes (either required or optional). Also, since the attribute values are all stored in the same table, it is possible to filter on attributes irrespective of the type (or sub-type) of the product. For example to get all items cheaper than 50 dollars (in the other approach we may have had to look in dozen of tables for that).
Back to the "drill-down" feature...
Once an initial search is performed (say searching all products where name [full-text indexed] contains the word "screen"), the ProductAttributes table can produce the distinct list of all different AttributeID (hence attribute name by lookup in Attributes table) for product satisfying this first search criteria.
Upon the user selecting a given attribute (say "Manufacturer", the ProductAttributes table can produce the distinct list of manufacturers (along with the number of products for each manufacturer). (alternatively such info can be searched initially rather than lazily, when the the user requests it).
The user then selects a given Manufacturer (or several), and a new query is ran to reduce the initial results list. The list of possible Attributes (and within each attributes the list of possible values) decreases, since some products (entities) initially selected are now excluded.
The process continues, providing the end user with guided search into the catalog. Of course the user may backtrack etc.
To maybe help with this wordy explanation (or maybe to further confuse the reader...) the following snippet provides a more precise indication of way this structure can be used to implement searches. This code is adapted for the table names used in the explanation above and may include a few typos, but generally provide the flavor of things. Also, this is written with a Common Table Expression (CTE) but could well be written as a subquery. Also not the that we do not join with the logical schema (meta data) tables, but that could be done too, to get the attribute names, type name and such, directly in the resultset.
As hinted earlier the queries and logic supporting this architecture are more complicated but also more versatile and tolerant of changes in the type of items stored and their attributes. Of course, this type of query is generated dynamically, based on the current list of search criteria supplied by the end-user.
WITH SearchQry AS (
SELECT ROW_NUMBER() OVER (ORDER BY P.EntityId ASC) AS RowNum,
P.EntityId AS EId
FROM Products P
INNER JOIN ProductAttributes PA1 ON P.EntitityId = PA1.EntityId and PA1.AttributeID = <some attribute id, say for Manufacturer>
INNER JOIN ProductAttributes PA2 ON P.EntitityId = PA2.EntityId and PA2.AttributeID = <some other attribute id, say for Color>
-- here for additional PAn JOINs as more criteria is added
WHERE P.ProductType IN (ProdId_x, ProdId_y, ProdId_z) -- for example where these x,y,z Ids correspond to say "TV Sets", "LapTop Computers" and "PDAs" respectively
AND PA1.Value = 'SAMSUNG' -- for example
AND PA2.Value = 'YELLOW' -- for example
GROUP BY P.EntityId
)
SELECT P.EntityId, PA.AttributeId, PA.Value -- PA.IntValue (if so structured)
FROM (SELECT * FROM SearchQry WHERE RowNum BETWEEN 1 AND 15) AS S
JOIN ProductAttributes PA ON PA.EntityId = S.EId
INNER JOIN Products P on P.EntityID = PA.EntityId
ORDER BY P.EntityId, P.AttributeId -- or some other sort order
Uzun açıklama için üzgünüm, orada [muhtemelen] belki bu online daha iyi bir açıklaması var, ama ben bulamadım ...