django-typed-models
django-typed-models copied to clipboard
Better docs to abandon prejudice
A thread[1] on django-devel showed, that there are fears of single table inheritance.
- There is one table which holds all data.
- STI reduces the database to key-value store
- All values are nullable
AFAIK there are two tables for this:
class Animal(TypedModel):
pass
class Canine(Animal):
pass
class Fruit(TypedModel):
pass
class Aple(Fruit):
pass
It is very easy to make one column not nullable: Add a constraint which checks the type column and the column which should be not nullable. It could be implemented in django typed models to implemented this:
Pseudocode for constraint:
if type=="Aple":
check color is not NULL
Thread on django-devel https://groups.google.com/d/msg/django-developers/-UOM8HNUnxg/keyHsbGE6WgJ
Sure thing. I'm pretty rubbish at writing docs unfortunately.
I replied to the thread. Will wait a bit to see if Russell KM replies, since I don't understand his key-value-store objection at all. Maybe he'll shed some light on his understanding of STI
Yes, the problem here is not technology. It is human fear. You don't need to care about 1M NULL values in columns. Modern databases handle this very well.
Related: Jacob Kaplan-Moss "Django gotcha: concrete inheritance" http://jacobian.org/writing/concrete-inheritance/