Files
2012-02-21 01:15:00 -05:00

1 line
4.6 KiB
JSON

[{"user_id": 960, "stars": [], "topic_id": 5649, "date_created": 1297709941.416971, "message": "Just ran into this issue where some code extends another model to act like a OneToOneField. Just curious for some insider perspective on which is better: subclassing or OneToOneField.", "group_id": 81, "id": 103356}, {"user_id": 960, "stars": [], "topic_id": 5649, "date_created": 1297709950.9027431, "message": "I have some ideas as to which way this is going to go...", "group_id": 81, "id": 103357}, {"user_id": 3580, "stars": [], "topic_id": 5649, "date_created": 1297711870.717953, "message": "@alex, I disagree. I think there's still the decision regarding whether to subclass (single table inheritance) or OneToOne field with parent_link (multi-table inheritance).", "group_id": 81, "id": 103744}, {"user_id": 7, "stars": [], "topic_id": 5649, "date_created": 1297711914.0484779, "message": "Subclassing is MTI, unless you provide Meta.proxy = True", "group_id": 81, "id": 103764}, {"user_id": 960, "stars": [], "topic_id": 5649, "date_created": 1297710638.6598899, "message": "I'm talking about OneToOneField and class MyModel(SomeOtherModel) being generally the same. Which one's the preferred way to get to that outcome.", "group_id": 81, "id": 103470}, {"user_id": 7, "stars": [], "topic_id": 5649, "date_created": 1297711810.8771551, "message": "congrats you have your answer", "group_id": 81, "id": 103715}, {"user_id": 3580, "stars": [], "topic_id": 5649, "date_created": 1297711898.5585251, "message": "or.. am I missing something?", "group_id": 81, "id": 103757}, {"user_id": 3580, "stars": [{"date_created": 1297710602.0433731, "user_id": 177}], "topic_id": 5649, "date_created": 1297710587.2056401, "message": "I guess I tend to think table/query centric but for me that's where my head is. OneToOne has the benefit of deconstructing an entity. That's handy if the pieces have independent lifetimes, different usage/fetching patterns (or costs). Are you talking about OneToOneFields in general, or specifically the parent_link=True pattern for accomplishing inheritance in the database?", "group_id": 81, "id": 103461}, {"user_id": 3580, "stars": [], "topic_id": 5649, "date_created": 1297710745.2698121, "message": "So... if I'm following then, first I'd decide if this isn an is-a.. A good clue would be whether or not one MyModel could ever exist without the fields in SomeOtherModel. If not, then we're probably looking at a good fit for inheritance.", "group_id": 81, "id": 103487}, {"user_id": 3580, "stars": [], "topic_id": 5649, "date_created": 1297710852.625526, "message": "Once you've decided to inherit.. then the question I'd ask is whether or not you want all of the fields in the same table. Other than pretty esoteric concerns, that would depend for me on whether I might need things to have a relationship (foreign key) to the base class or not (if so, maybe OneToOne two-table inheritance is a good idea). When in doubt.. I'd keep it simple (and reduce fetches), and just inherit. I guess I'm saying just extend unless you have a good reason to complicate things.", "group_id": 81, "id": 103514}, {"user_id": 3580, "stars": [], "topic_id": 5649, "date_created": 1297710878.9560671, "message": "All of that said, if you have a more concrete example we could work through that.", "group_id": 81, "id": 103522}, {"user_id": 218, "stars": [], "topic_id": 5649, "date_created": 1297711764.3953609, "message": "so I think after that, it just becomes semantics.", "group_id": 81, "id": 103699}, {"user_id": 3580, "stars": [], "topic_id": 5649, "date_created": 1297712056.806607, "message": "Gotcha. yeah, I think your interpretation of the original question makes sense.", "group_id": 81, "id": 103808}, {"user_id": 218, "stars": [], "topic_id": 5649, "date_created": 1297711720.914398, "message": "@tswicegood Subclassing is implemented as a OneToOneField", "group_id": 81, "id": 103684}, {"user_id": 7, "stars": [], "topic_id": 5649, "date_created": 1297711807.9108839, "message": "Ask yourself, if I didn't have a database would I subclass or have a member variable", "group_id": 81, "id": 103714}, {"user_id": 3580, "stars": [], "topic_id": 5649, "date_created": 1297711960.8447649, "message": "or Meta.abstract = True in the base... yes?", "group_id": 81, "id": 103782}, {"user_id": 7, "stars": [], "topic_id": 5649, "date_created": 1297711968.940671, "message": "yeah", "group_id": 81, "id": 103784}, {"user_id": 7, "stars": [], "topic_id": 5649, "date_created": 1297711995.510165, "message": "sorry, OP asked about OneToOne vs subclassing (with implit 121) so I assumed MTI was the order of hte day", "group_id": 81, "id": 103789}]