Django Multi Table Inheritance and Preserving Child and Child History

4 views
Skip to first unread message

Malik Rumi

unread,
Aug 30, 2016, 6:52:01 PM8/30/16
to Django users
Note: I originally posted this to http://dba.stackexchange.com/questions/147680/django-multi-table-inheritance-and-preserving-child-and-child-history,  but 7 days and ZERO responses is not working for me. 

Place can have many different one to one fields, that’s why it can have bookstore, restaurant, and hardware store. But can the same place be both a bookstore and a restaurant at the same time? Now if the bookstore and restaurant tables don't have the same pk as place, I would think the answer is yes. But I also know that unless you put parent_link=True on it, erasing the child row automatically deletes the parent row.


My use case is to preserve the history of Restaurant despite it’s having now become a Bookstore, and if a Restaurant is simultaneously a Bookstore, to be able to keep both places in my db. Is the best way to do this with a fk to each of the bookstores, restaurants and hardware stores instead of either a OneToOne or multi table inheritance? Or is there some other way I’m not aware of? 


This has to be a solved problem, but so far I haven't found it. I'm currently looking at NFL databases because players can be on more than one team, (albeit not at the same time), and they have a recorded history of their team and individual stats - to see if I can hack those into what I want.


I'm even willing to consider an ArrayField or Hstore. I'm on Postgres 9.4 and trying to maintain 3NF. All wisdom accepted. Thanks.

Reply all
Reply to author
Forward
0 new messages