Figure C-2 shows a partial model of the winestore. In this diagram, you can see the relationship between wines, wineries, and regions. Each wine has attributes such as a name
, type
, and a description
. A wine is made by a winery, and each winery has attributes such as a name
, phone
, and description
. Many wineries are located in a region, where a region has a map
and description
.
Figure C-2. A simple ER model showing the relationship between wines, wineries, and regions
ER diagrams aren't complicated, and we have already illustrated most of the features of ER modeling in Figure C-2. These features include:
- Rectangles
-
Represent entities-that is, objects being modeled. Each entity is labeled with a meaningful title.
- Diamonds
-
Represent relationships between entities; a relationship is labeled with a descriptive title that represents how the entities interact.
- Ellipses
-
Represent attributes that describe an entity.
- Lines
-
Connect entities to relationships. Lines may be without any annotation, be annotated with an
M
and anN
, or annotated with anM
and a1
(or anN
and a1
). Annotations indicate the cardinality of the relationship; we discuss cardinality later in this section. - Lines
-
Connect attributes to entities. These lines are never labeled.
Other ER modeling tools include double ellipses, dashed ellipses, and double lines; we use some of these advanced features later in this appendix. Useful references for more advanced ER modeling-and enhanced ER (EER) modeling-are provided in Appendix E.
Case Study: Modeling the Online Winestore
To illustrate how ER (Entity relationship) modeling can be used to effectively design a database, we return to our online winestore.
Entity relationship model (ER model) in software engineering is an abstract way to describe a database.
System requirements analysis
The first step in developing a database model using ER modeling is to consider the requirements of the system. The requirements for the online winestore were described in Chapter 1 and are typically gathered from a scope document, customer interviews, user requirements documents, and so on.
Many of the requirements affect development of the ER model, while others are more general system requirements used to develop the web database application. One of the skills of ER modeling is extracting the requirements that impact on the database design from those that are functional elements of the system.
Once a system requirements analysis is complete, and the detailed requirements written down, you can proceed to the conceptual database design using the ER modeling techniques.
ER Modeling Entities
Entities are objects or things that can be described by their characteristics. As we identify entities, we list the attributes that describe the entity. For example, a customer is an entity that has a name, an address, a phone, and other details.