Presentation is loading. Please wait.

Presentation is loading. Please wait.

Entity-Relationship Diagrams

Similar presentations


Presentation on theme: "Entity-Relationship Diagrams"— Presentation transcript:

1 Entity-Relationship Diagrams

2 Species Pokémon Moves type level name name status type id Instance Of
Can Learn Has Moves type id

3 Purpose of Entity-Relation Model
The E/R model is a way to roughly describe the system we want to represent in a database The model represents some of the constraints we want to capture It may seem silly at first, but design is serious business These diagrams can help illustrate potential ways to represent your specific system You can't have an efficient database without good design

4 Entity Set Entity = "thing" or object
Entity Set = collection of similar entities Akin to a class in object-oriented languages Attribute = property of (the entities of) an entity set. Attributes are simple (non-compound values): integers, strings, etc. You should not have an attribute that is a collection (no lists, structs, sets, etc.)

5 Entity Sets and Attributes
In an Entity-Relationship Diagram: Entity set = rectangle Attribute = oval (with a line to the rectangle representing its entity set) Here, "Species" is the entity set. "type" and "name" are attributes of "Species". Every entity in "Species" has a "type" and "name". Species type name

6 Relationships A relationship connects two or more entity sets.
Each is represented by a diamond, with lines to the entity sets involved. Species Instance Of Pokémon type level name name status

7 Value of an Entity Set The current "value" of an entity set is the set of entities that belong to it. Pokémon name level status aaabaaaajss 69 Sleeping AIIIIIIRRR 31 NULL AATTVVV 29 Paralyzed Species name type Pidgeot Flying Lapras Ice Venomoth Poison

8 Value of a Relationship Set
The current "value" of a relationship set is a set of tuples with one component for each related entity set. Instance Of Pokémon Species aaabaaaajss Pidgeot AIIIIIIRRR Lapras AATTVVV Venomoth

9 Multiway Relationships
Relationships can connect more than two entity sets. Suppose that the relationship set "Battle" involves the entity sets "Pokémon", "Trainers", and "Music". Battle level Trainers name Pokémon name status theme Music

10 Multiplicity of relationships
One-to-One Many-to-one Many-to-many Species Pokemon Trainer has Instance of has Cry Species Item

11 What is the multiplicity of character to costume?
Harry Robe Gandalf Jaime Armor Cape Mal Duster 1. One-to-One 2. One-to-Many 3. Many-to-One 4. Many-to-Many

12 Representing "Multiplicity"
One-to-One relationship has arrows entering both entity sets. Many-to-One relationship has an arrow entering the "one" side. Many-to-Many relationship has a line connecting both entity sets. A Rounded Arrow means "exactly one" Each entity of the first set is related to exactly one entity of the target set. Due to limitations of PowerPoint, I am using -> arrows to represent rounded ones and triangle arrows for normal ones. has Species Cry Each species must have one cry (rounded arrow) Each Pokémon can have at most one trainer (normal arrow) has Pokémon Trainer

13 What is the multiplicity of Trainer to Catchphrase?
1. Exactly-One-to-Exactly-One 2. One-to-One 3. Many-to-Many 4. Too often Trainer says Catchphrase


Download ppt "Entity-Relationship Diagrams"

Similar presentations


Ads by Google