Is a Relationship Just a Special Case of an Attribute?
Lets look at the properties that define an attribute as opposed to a relationship to see how well they combine:
Attribute ::= Name [ShortDescription] DataType Required
Relationship ::= RelatedObjectName Required Multiple Composed
The RelatedObjectName really maps to the data type of attribute. Relationships typically don’t have a short description (which is fine as it is optional for attributes). They both have “Required”, and attributes could usefully have a Multiple for some use cases to distinguish between single and multiple selects within value lists. Attributes are by definition composed (delete an object and it’ll delete its attribute values) and you could add a Name to a relationship – perhaps driven by descriptive purposes, so a User might have a WorksFor attribute with a data type of Company. In short, there are enough similarities between the initially proposed concept syntaxes that it would be possible to combine them. Interesting . . .
The next question is how you would distinguish attributes from relationships for the operations that might only be performed on one or the other. If you had a list of object names, if there was never a custom data type with a name identical to that of an object, you could figure out fairly easily whether an attribute was pointing to an object or not, but I’m not sure that would be a good limitation, so I’d probably want an Object Boolean to distinguish relationships from attributes.
So, the data is similar enough that we could merge it, but we’re going to use a Boolean to distinguish the two types of attributes (looking at this from an object modeling perspective you might decide that conceptually PrimativeAttribute and ObjectAttribute both subclass an abstract Attribute class). The question then is whether there would be any benefits at all in going down from three concepts to two. How many operations would be perform on both attributes and relationships? Initially I can’t really think of many (the generation of getters and setters for attributes irrespective of data type is the one thing that comes to mind).
Another way of looking at this would be to distinguish between composed objects that from an OO perspective are really just attributes with a complex data type and associated objects that are something “outside” of the object they are associated to. However, while conceptually this is an interesting approach, the code you write to pull related object data is actually pretty much the same whether the object is associated or composed (the only difference is cascading deletes for composed objects) so it isn’t really as useful as other distinctions.
You could square the circle conceptually by imagining composed relationships to have a data type of the composed object(s) and associated relationships to have a data type of a pointer to the associated object(s) (we’re talking conceptual model here – the way most of the code base is implemented it won’t treat composed and associate objects any differently from each other except is a small set of special cases). However, I’m not sure that we get any benefits by doing so.
In the end, while it is interesting to consider the idea of treating relationships as a type of attribute, I don’t yet see any compelling benefits so I’m going to go with the standard convention in ODL of having Objects, Attributes and Relationships and I’ll just keep my mind open to refactoring the grammar if it makes sense down the line.
Anyone else got any thoughts on this?!



In my current code generator I generate code that allows you to include up to two attributes from a parent object in a child object (hasOne relationship). I was lokking to extend that and was considering a sytax of object.attribute for the attributes of a linked object.
I would like to have some way to include data from child objects too and was considering structures or lists as a way to implement that.
Will look for you tomorrow to discuss it.
As I recall, the ER model for databases has this concept. But I could be wrong. In effect though, that's how I think of them. Not sure if that's worth much though.
My immediate thought to that is that I don't see any value in it. I mean, I might think of it like that, but to model it like that, I don't like. I suppose it does hide more information, but at the same time, that information in my eyes, at least, is pretty important. This isn't a strongly held position though, so I could easily be swayed with some evidence.
When I was talking about ER models, I mean that you can model/view a relationship as a special type of attribute. I could be wrong, of course, but I thought there was a way to do so. You wouldn't keep the related object within it, but the relationship itself can have attributes. Ahh, maybe I just cleared it up for myself. Perhaps I didn't mean what I thought I meant the first time =)
RE: the school and work and your site: Yeah, I'm in the middle of writing a paper that's due in a couple of hours, and I needed a break (been at it since 6 this morning + several hours yesterday). Anyway, for my break, I thought, "let's see what Peter Bell has to say today."
It is a pretty heavy reading schedule you provide. I'm sure I'll slack off later in the semester when I've got more than a paper to write.
And work, it is slow today, since I got blocked by a technical problem that needs to be fixed before I can continue. The problem is, I have no idea how to fix it and no diagnostic information to go on, so I'm waiting on another site's tech support to see if they know anything.
Wow, can I make this comment any longer? =)
Yes. Back to the paper. This was the last post to read for today (that I know of). =)
Good luck with the paper!