4

I'm drawing an ER diagram for an ecommerce site that I'm building, and noticed something: the diamond that I am drawing between two models (or entities), which I understand is meant to symbolize the relationship between the entities, seems irrelevant.

The diagram could be drawn without the diamonds, and it would still show everything that I am conveying if I just connected entities with -|---|0- and similar connectors, without a diamond in between.

So what are the diamonds for?

3

As James K already said, there is more than one set of rules for forming ERDs, and more than one answer to your question. But, to deal with your question from a generic point of view, here goes.

Sometimes the diamond is irrelevant. The line between two boxes depicts the relationship, and often says everything that needs to be said. Here are some cases where the diamond makes the diagram more legible.

First, relationships with attributes. Some ERD diagrammers allow attributes to describe relationships in addition to entities. For example, if an enrollment is a relationship between a student and a course, then the grade the student got might be an attribute of the relationship. It is certainly not an attribute of just the student, or of just the course. If you follow this practice, and if you list attributes inside of boxes, it behooves you to put a diamond in for the enrollment relationship and to put the grade attribute inside of the diamond.

Some ER diagrammers prefer to make enrollment into an entity, instead of leaving it as a relationship. In that case, the diamond becomes a box.

Second, some relationships are not binary, but ternary, quaternary, or n-ary. That is, instead of one line connecting two boxes, there are several lines connecting 3, 4, or more boxes. In this case, those lines all come together somewhere. It behooves you to put a diamond in where they all come together.

As an example, an airline reservation might have a line connecting it to the passenger, another line connecting it to the flight, and a third line connecting it to the airport where the passenger will board.

Again, some diagrammers prefer to to make n-ary relationships into entities. And again, that means using a box in place of a diamond.

There's a fancy word for turning a relationship into an entity. It's called "reifying".

Having said all that, the majority of ERDs I've ever made for myself have no diamonds on them.

3

Peter Chen, who invented the ER model and the notation containing diamonds for relationships, distinguished two kinds of relations - entity relations and relationship relations. Each were intended to be physically implemented as a table, and hence the shapes showed the physical parts of the model.

A relationship can be n-ary, not just binary, and can have attributes - using lines "under-represents" the importance and structure of relationships. Lines may also lead to confusing relationships with foreign key constraints.

For more information, see The Entity-Relationship Model - Toward a Unified View of Data

2

The answer to your question depends on the rules of the diagramatic representation implemented by the tool you're using.

One possibility is that you're looking at a logical view of an M:N relationship, and the diamond represents the physical table that will be generated to support that relationship. (From an ER point of view, it doesn't exist.)

I have never seen an ER methodology that used a diamond to represent optionality or cardinality. Those things actually do matter, and you've correctly taken note of them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.