Data Model for handling dynamic attributes/fields

Shadab

Well-known member
I'm developing an addon, a part of which would require support for dynamic attributes. By dynamic attributes I mean that I, as a developer, won't be deciding the attributes for a content type. The set of attributes that would apply to a content type would be decided by the end-user. And this "set" would vary depending upon other factors, such as the parent node.

The problem is deciding which data model to use for storing those attributes and the corresponding values. The EAV model comes to mind, which is perfectly fine for storing this data and is highly extensible; but then searching and comparing data would become a nightmare. Or would it not?

Another "solution" is to use a separate single table for storing the metadata: attributes as column names and (nullable) values in rows. Insertion, deletion and searching for data would be very easy; but adding and removing attributes (columns) would be painfully slow on large tables.

Now unless there's some other model which I don't know of, that fits the requirement,
help me choose the lesser of these two evils. :confused:
 
Yeah, I think EAV is the better approach here, unless you want to require users install a non-relational database like CouchDB or something. :p The second approach would be drastically inefficient unless you only had like 2 content types and a couple dozen attributes, but even then it wouldn't scale for large datasets like you said.
 
unless you want to require users install a non-relational database like CouchDB or something.
Wish I could do that, but this is for a free addon. :P

The second approach would be drastically inefficient unless you only had like 2 content types and a couple dozen attributes, but even then it wouldn't scale for large datasets like you said.
Although there's only one content-type for which the user will decide the attributes; I can't possibly know how many such attributes the user will come up with.
 
Top Bottom