Use Sophia to knock out your gen-ed requirements quickly and affordably. Learn more
×

Tables as Entities

Author: Sophia

what's covered
This tutorial explores the creation of entities using a movie rating scenario in an entity-relationship diagram (ERD). You learn entity creation in two parts:
  1. Movie Ratings Scenario
  2. Defining Entities

1. Movie Ratings Scenario

Before we can begin to create tables as entities in an ERD, you need to know some of the basic criteria and business rules for a specific scenario. Let us look at a movie rating scenario where a new database will have to be created.

think about it
Imagine that an organization would like to create a movie rating application, where users would be able to rate movies on a numeric scale and provide textual feedback about the movie. The date that the review was submitted should be stored. There are some details about the movie that should also be stored, including the actors, movie title, description, release date, and genre(s). The users will log into the system using a username/password combination, and their first name, last name, and date of birth will also be stored.


2. Defining Entities

This scenario gives us some information to help us define what the entities are that you must create in an ERD. It is important that you stick with the details in the scenario rather than adding in extra details that the organization may not need. For example, a movie has many other attributes like the producer(s), director(s), and other individuals involved. However, the organization is not asking for those details to be tracked. Some of the details may need some of our domain knowledge to help define some of the relationships as well. Let’s take a look at what some of these entities would be, by identifying the business rules from the scenario:

  • A movie can belong to multiple genres, and a genre can have multiple movies.
  • A user can submit multiple ratings, and a rating can only belong to a single user.
  • A rating is only for a single movie, and a movie can be rated multiple times.
  • A movie can have many actors, and an actor can act in many movies.
The first step here is to create your entities and their relationships. Remember back to what you learned in the last Unit about Chen's notation, in this first step, you don’t worry about any of the cardinalities or attributes. Rather, you first start by drawing a rectangle for each entity, or table. Each table name should be singular, such as "User" rather than "Users," or "Movie" rather "Movies":

Chen's notation tables

The next step, once you have the entities defined, is to display the direct relationships between the tables. Here, you have a relationship between the user and rating, rating and movie, movie and actor, and movie and genre:

Chen's notation links

You have now done the first step in our ERD, by identifying the entities for your database.


summary
In this tutorial, you learned that entities are defined by using rectangles in Chen's notation, with a solid line between them to signify a relationship between the entities. You were able to create entities in an ERD for the beginning of a movie ratings scenario using some business rules from the scenario.

In the next tutorial, you will learn how to add attributes to entities in an ERD, which are indicated in Chen's notation as ovals.

Source: Authored by Vincent Tran