Re: Another view on analysis and ER

From: David BL <davidbl_at_iinet.net.au>
Date: Thu, 6 Dec 2007 11:53:09 -0800 (PST)
Message-ID: <fad91a4e-4a90-4a1c-8250-900264223a68_at_s8g2000prg.googlegroups.com>


On Dec 6, 5:37 pm, Jon Heggland <jon.heggl..._at_ntnu.no> wrote:
> Quoth David BL:
>
> > By contrast I think a relationship is characterised as only being
> > identified by the entities that it relates.
>
> > Now I see the same distinction being made in a propositional
> > encoding.
>
> > The intensional definition of the following predicate implicitly
> > assumes Husband, Wife and Location correspond to entity types that can
> > be identified using domain values. Evidently marriage is merely a
> > relationship between them.
>
> > married(Husband, Wife, Location) :- Husband married Wife at
> > Location
>
> So you intend that Location is necessary for identification?

I wasn't actually intending that Location be necessary for identification of a marriage. I'll make the intensional definition clearer:-

    married(Husband, Wife, Location) :-

        Husband is *currently* married to Wife
        and they (last) got married at Location

Candidate keys are { Husband } or { Wife }, enforcing monogamy integrity constraints.

> What if
> Location does not correspond to an entity type? I assume that might be
> the case if it were simply a spatial coordinate. Is marriage still a
> relationship? If not, what is is?

I agree that it is strange to think of a spatial coordinate as an entity type.

I guess this example illustrates why ERM allows relationships between entities to support attributes.

> (And "merely" a relationship? Are entities better than relationships in
> some way?)

No definitely not. I seem to have an unfortunate habit of using "merely" when I should use "only".

Maybe my subconscious was accounting for the notion that entities are characterised as things in our perception that for some reason "deserve" to be identified rather directly - often with their own special name, whereas relationships are identified indirectly.

> > By contrast the following predicates are consistent with thinking of a
> > marriage itself as an entity
>
> > husband(MarriageId, Husband).
> > wife(MarriageId, Wife).
> > location(MarriageId, Location).
>
> > or maybe just
>
> > married(MarriageId, Husband, Wife, Location)
>
> > Now whether one "thinks in ER" or "thinks in propositional encodings",
> > there has to be good reason to introduce a MarriageId.
>
> Perhaps marriage certificates has a unique number stamped on them, and
> you want to record this in your database.

Yes, that could be a reason. Consider the following intensional definition

    married(MarriageId, Husband, Wife, Location) :-

        The marriage identified by MarriageId was
        between Husband and Wife at Location.

In this case the relation can record marriages that are no longer current, and the only candidate key is { MarriageId }.

> Anyway, your first predicate breaks down if two people can marry each
> other more than once on the same location, which is the case in many
> parts of the world.

No, the first predicate doesn't break down if the intension is *current* marriages.

> I'd suggest you add a DateTime as well.

Yes, that would be useful in practise.

> Does that
> make the predicate an entity? Assuming monogamy, it can be identified by
> { Husband, DateTime }, { Wife, DateTime } or perhaps even { Location,
> DateTime } if we preclude mass weddings. What if the DateTime
> "corresponds to an entity type"? (What determines whether there is such
> a correspondence?)

Well I can see you are technically picking holes in my "characterisation" of entity, but I wasn't really putting forward a definition. I think the "characterisation" was very informal and more along the lines of being necessary but not sufficient.

Actually, I would prefer to steer clear of trying to pin down such informal words as "entity" and "relationship".

However, I still believe particular entity types are implicit in the intensional definitions of the predicates. How can they not be?

Although the intensional definitions are strictly outside the mathematical formalism of the RM, they are nevertheless fundamental to the meaning and purpose of the database.

> > Aren't you implying that a propositional encoding doesn't commit you
> > to a decision about whether a marriage is implicitly or explicitly
> > identified? I fail to see how that is possible.

This is the question I would like you to comment on! Do you agree that a predicate can treat a marriage like a relationship, or otherwise like an entity, which seems at odds with this idea of a neutral logical layer?

> You define relationships as anything that can be identified /only/ by
> its related entitites---if there is an alternate key, the thing is an
> entity. Correct? What is the rationale behind this rule?

It is only a rather vague characterisation, and about as precise as the entity/relationship distinction deserves!

My rationale is as follows: If you study some real life ER diagrams you will tend to find that entities are associated with nouns, and relationships are associated with verbs or actions. Here are some binary relationships taken from chapter 14 in Date's Introduction to Database Systems

      entity relationship entity


     supplier     ships          part
     department   employs        employee
     employee     works on       project

Now in natural language we don't normally name instances of verbs or actions, but instead name subject and object. Eg "Jack kicks John". We don't think of the kick action as an entity that needs to be identified independently of Jack and John. Furthermore a kick is less tangible - it has a fleeting existence.

Note furthermore that verb phrases include other types of relationships that don't correspond to actions, such as "is less than", "has" or "is the father of". Note how silly it would seem to name a particular instance of a "has" relationship - ie between a particular pair of entities.

> (And what if the alternative means of identification is also a
> combination of entities?)

Relationships won't tend to do that!

At this rather informal level of discussion, relationships are counterparts to relations and as we know, 1) tuple identifiers are not needed in the RM, and 2) it would be strange indeed if a proposition could be stated in some equivalent form on an alternative set of entities. Received on Thu Dec 06 2007 - 20:53:09 CET

Original text of this message