> Den 15/12/2014 kl. 14.42 skrev Felipe Faraggi <felipefara...@gmail.com>:
> 
> After a little digging I discovered this is called the Entity-attribute-value 
> model or EAV. And I am currently setting up a project in django in which my 
> data is very variable because we will be opening up to many APIs and they all 
> have their own table styles. So instead of having a rigid model, we've opted 
> for having a EAV model to stock everything with its own key-value pair.
> 
> So I would like to hear your general thoughts about this method (I've heard 
> some good/bad things about it) and your specific experiences with it and 
> django (if any).

An EAV approach is almost never what you want. Even when you think you do, you 
probably don't. Since you are coercing all your values to strings (coming from 
a PHP background, that may not seem like a problem!), you lose everything that 
an RDBMS offers in terms of data validation and integrity, referential 
integrity, indexing, efficient disk storage etc. Often things you only find out 
you need when your project or data volume grows large.

In my view, the only justification to EAVs is when you have a sparse object 
model. For example when storing patient diagnoses. Thousands of diagnose codes 
exist, but any single patient will only have values for very few of these codes.

If you have many data sources, I would suggest modeling each source truthfully 
in Django in its' own app, and handling whatever abstraction you need in Python 
code instead, using e.g. abstract models, class inheritance, mixins, custom 
managers or queryset chaining. Tables are cheap, and with Django models and 
data migrations you don't need to care that you're creating hundreds or 
thousands of them.


Erik

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/02866A6B-9693-4257-83F3-441482179247%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to