Entity-Relationship Diagrams – Understanding the Relationship Diamond

database-designerd

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?

Best Answer

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.