Elements of the E/R Model

Elements of the E/R Model

The most common model for abstract representation of the structure of a database is the entity-relationship model (or E/R model). In the E/R model, the structure of data is represented graphically, as an "entity-relationship diagram", using three principal element types:

a. Entity sets
b. Attributes
c. Relationships

We shall cover each in turn.

a) Entity Sets

An entity is an abstract object of some kind, and a compilation of alike entities forms an entity set. There is some resemblance between the entity and an "object" in the sense of object-oriented programming. Similarly, an entity set bears some similarity to a class of objects. However, the E/R model is a static concept, involving the structure of data and not the operations on data. Therefore, one would not expect to find techniques associated with an entity set as one would with a class.

Example : We shall use as a running example a database about movies, their stars, the studios that produce them, and other sides of movies. Each movie is an entity, and the set of all movies composes an entity set. Similarly, the stars are entities, and the set of stars is an entity set. A studio is another type of entity, and the set of studios is a third entity set that will appear in our examples.

er model variations

b) Attributes

Entity sets have combined attributes, which are properties of the entities in that set. For example, the entity set Movies might be given attributes such as title (the name of the movie) or length, the number of minutes the movie runs. In our version of the E/R model, we shall presume that attributes are atomic values, such as strings, integers, or reals. There are other variations of this model in which attributes can have some limited structure; see the above box on "E/R Model Variations".

c) Relationships

Relationships are connections among two or more entity sets. For example, if Movies and Stars are two entity sets, we could have a relationship Stars-in that connects movies and stars. The intent is that a movie entity m is related to a star entity s by the relationship Stars-in if s appears in movie m. While binary relationships, those between two entity sets, are by far the most common type of relationship, the E/R model allows relationships to include any number of entity sets. We shall postpone discussion of these multiway relationships until "Multiway Relationships".

Entity-Relationship Diagrams

An E/R diagram is a graph representing entity sets, attributes, and relationships. Components of each of these kinds are represented by nodes of the graph, and we use a special shape of node to indicate the kind, as follows:

● Entity sets are represented by rectangles.
● Attributes are represented by ovals.
● Relationships are represented by diamonds.

Edges connect an entity set to its attributes and also connect a relationship to its entity sets.

Example : In the following figure is an E/R diagram that represents a simple database about movies. The entity sets are Movies, Stars, and Studios.

entity-relationship diagrams

The Movies entity set has four attributes: title, year (in which the movie was made), length, and film Type (either "color" or "Black & White"). The other two entity sets Stars and Studios happen to have the same two attributes: name and address, each with clear meaning. We also see two relationships in the diagram:

1. Stars-in is a relationship connecting each movie to the stars of that movie. This relationship consequently also connects stars to the movies in which they appeared.

2. Owns connects each movie to the studio that owns the movie. The arrow pointing to entity set Studios in the above figure indicates that each movie is owned by a unique studio. We shall discuss uniqueness constraints such as this one in "Multiplicity of Binary E/R Relationships".



Tags