We start with ideas about the information we want to model and
render them in the E/R model. The abstract E/R design is then
converted to a schema in the data-specification language of
some DBMS. Most commonly, this DBMS uses the relational
model.
Figure: Database modeling and implementation process
The structure of data is represented graphically, as an "entity-
relationship diagram,“ using three principal element types:
1. Entity sets: An entity is an abstract object of some sort, and a
collection of similar entities forms an entity set.
2. Attributes: Entity sets have associated attributes, which are
properties of the entities in that set.
3. Relationships: Relationships are connections among two or
more entity sets.
An E/R diagram is a graph representing entity sets, attributes, and
relationships. Elements 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.
Product address buys
Entity Attribute Relation
Product (name, price, category)
Company (name, stockprice)
Person(name, address)
What Would be the ERD?
name category
name
price
Makes Company
Product
stockprice
Buys
Employs
Person
address name
Let us design a database for a Lab, including
information about student and team. Information
about a student includes id, name (e.g., first name,
last name), grade. A team has team number and
grade. We also need to record the student(s) who
form team. A student can be in one team, a team
can have many students. Draw the E/R diagram for
this database.
lastname firstname
name
studentGrade
ID
Forms Team
Student
teamNumber teamGrade
one-one:
1 a
2 b
3 c
d
1 a
many-one 2 b
3 c
d
1 a
2 b
many-many 3 c
d
makes Company
Product
buys
employs
Person
purchaseDate
Product Buys Person
lastname firstname
name name category
studentGrade
ID price
Student Product
18
There are several ways this constraint could be
enforced:
1. We could forbid the deletion of a referenced entity.
2. We could require that if a referenced entity is deleted,
then all entities that reference it are deleted as well.
Student Forms Team
20
Example:
Representing a constraint on the number of students per team
<=5
Student Forms Team
21
Entity sets are weak when their key attributes come from other
classes to which they are related.
This happens if:
- part-of hierarchies
- splitting n-ary relations to binary.
Team affiliation University
sport number name 22
25