This tutorial explores the creation of attributes to add to entities in an entity-relationship diagram (ERD). You learn attribute creation in two parts:
- Movie Ratings Example
- Defining Attributes
1. Movie Ratings Example
Let us return to the movie-rating scenario: An organization would like to create a movie rating application where users 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 details about the movie, including the actors, movie title, description, release date, and genre, that should also be stored. The users will log into the system using a username/password combination and the system will also store their first name, last name, and date of birth.
In the prior tutorial, you defined your entities as follows:
2. Defining Attributes
You should now define what the attributes are for each of the entities. In looking at your scenario, you can define the following:
- For the User entity, you can define the attributes username, password, first name, last name, and date of birth. In Chen’s notation, you signify attributes as an oval, with a line that connects the attribute to the entity:
- The Rating entity would have the attributes numeric rating and textual rating:
- The Movie entity would have the attributes title, description, and release date:
- The Genre entity would consist of the genre name:
- The Actor entity would have the attributes first name and last name:
Altogether, the ERD with just the entities and attributes would look like the following:
Visually, you can easily determine which items are entities and which items are attributes. To distinguish the primary key attributes from the other attributes in the table, the primary key attributes should be underlined within the oval. The primary key helps to uniquely identify each row within the table where each value must be unique and must have a value.
-
Chen's notation can get very busy once there are many attributes and entities. It’s a great starting point, but if needed, switching to Crow’s foot notation can make it visually easier to follow.
In this tutorial, you learned that in Chen’s notation, you signify (define) attributes as an oval, with a line that connects the attribute to the entity. Again using the movie ratings example, you were able to create attributes for the ERD. Remember for ERDs that can get very large based on the number of entities and/or attributes, switching to the Crow's foot notation may make your ERD easier to follow.