3460 Posts in 1064 Topics by 739 members
|Go to End|
21 February 2010 at 1:52pm
I have a Resume data object with a number of detail data objects - Employment, Education, Competencies. These are all one-to-many and straight-forward to code. Each detail object will always have one master Resume object.
I also have an Addresses data object, which is linked to a Resume, and then optionally to any of the detail objects, e.g. the address of an employer (Employment), the address of a school (Education), etc. Each of the detail objects may optionally point to one address.
I am doing this so that all the addresses can be handled in the same way and stored in the same database table for convenience. What is the best way to model this? Each Address object will have a parent that could be a Employment record *or* an Education record.
Would I just set $has_one(Address) for each detail object (Employment, Education, etc) but ignore the relationship in the opposite direction, handling it in code instead?
22 February 2010 at 1:59am Last edited: 22 February 2010 2:03am
Okay, let me put it another way:
I have three data objects (A, B and C), all with a common parent. That makes them all related. So far so good.
Now each of those three data objects has an optional one-to-one relationship with another data object (Address). Any one of those three objects could have its own Address object; each Address object has just one owner, i.e. it is a detail of just one of the data items in one of the three objects.
From an administrator's point of view, when editing any of A, B or C, the fields from Address should be tagged on the bottom of the form. It should look like the Address is a part of A, B or C, even though the address is stored in a separate data store.
Is there a simple way to achieve that? If the address details need to be put into a pop-up form, fair enough (just for the admin interface to the raw data, which is just there for me to fix problems with the data), but that relationship one-to-one puts the relation the opposite way around to the usual master/detail mixed forms.
Does that make sense?
The relations are:
Master ---< A
Master ---< B
Master ---< C
A +--- Address
B +--- Address
C +--- Address
PS How about markdown support for the forums? Markdown is very intuitive, and reads well even before it is transformed.
22 February 2010 at 8:39am Last edited: 22 February 2010 8:39am
"Would I just set $has_one(Address) for each detail object (Employment, Education, etc) but ignore the relationship in the opposite direction, handling it in code instead?"
Yeah, that's probably your best bet. Sapphire doesn't handle one-one relations very well (you end up with what looks like two broken one-many pairs), so it is usually cleaner to do as you say. From your first post I think you are on the right track.
"PS How about markdown support for the forums? Markdown is very intuitive, and reads well even before it is transformed."
+1. BBCode is a bit 2002, right?
22 February 2010 at 8:51am
I've been spoiled a bit using markdown in other projects, and love it. I'm not sure if is does the N-level nested quotes like bbcode does, but perhaps that is a good thing.
Thanks for the feedback. I can carry on the line I'm following, knowing that I haven't missed out some obvious functionality of SS or Sapphire.
|Go to Top|