tags:

views:

127

answers:

1

I need to store various info about some movies, books, games, and maybe other media. Starting from publisher to disc count in DVD-box. At first i thought about abstract Item model, with children Book, Movie, Game. But it's all hard-coded and not very scalable, i think. What if i would need to add some new item type?

Then I've read about virtual fields here http://stackoverflow.com/questions/590921/django-designing-models-with-virtual-fields that got my attention. But looks DB heavy and not very search-able, am i wrong?

What are the best techniques for such cases?

+1  A: 

I think you want a concrete Item superclass (since it will likely have common fields, ie title, copyright_date, publisher, etc) and subclasses for each subtype (and further sub-sub-classes if you like, ie from Toy to ActionFigure with number_of_joints field), using multi-table inheritance.

If you are just querying the Item model, this will be fast since Django's ORM won't join to the other tables (and will return Item objects which can then be converted to their "native" type by referencing item.subclassname. Likewise, you can query each of the subclass models individually with some efficiency.

Regarding searchability, if you are using an indexer efficiency doesn't matter too much since the indexing happens infrequently.

Eric Drechsel