Professional Documents
Culture Documents
From Class Diagram To Relation Schema PDF
From Class Diagram To Relation Schema PDF
Creating Databases
There is a class diagram of the Car Rental database below. This diagram
has been drawn using UML classes and associations. The name of the
entity is in the upper box. The attributes for the entity are written in the
lower box. The primary key candidates are underlined.
Picture 1. The Class Diagram of the Car Rental database A customer has
made one or more (1..*) car rentals. A certain car rent always belongs to
a certain customer (1) and there is always a specific car (1) that is
rented. A car is rented out several times. If the car is a new one, it might
not be rented out yet (0..*). A car has a certain car type (1). There is at
least one car in each car type (1..*). In the class diagram datatypes can
be written. It might be a good idea to think about datatypes at this point.
You have to define the datatype for each attribute before you can
implement the database.
http://www2.amk.fi/digma.fi/www.amk.fi/opintojaksot/0303011/1146161367915/1146161783414/1146163048742/1146163155917.html 1/3
1/20/2018 From Class Diagram to Relation Schema
Relation Schema
The name of the relation is written with capital letters. The primary key is
underlined and foreign keys are in italics.
http://www2.amk.fi/digma.fi/www.amk.fi/opintojaksot/0303011/1146161367915/1146161783414/1146163048742/1146163155917.html 2/3
1/20/2018 From Class Diagram to Relation Schema
For this kind of relationship you must define a new relation between the
two existing relations. This will split the many-to-many relationship to two
one-to-many relationships. In the new relation there are the primary keys
of the existing entities. Note how the primary keys are formed.
If you have to save the year and the semester of the course that a
teacher is lecturing, the class diagram will be:
The relation schema for this diagram is defined (note where the year and
semester are to be written):
http://www2.amk.fi/digma.fi/www.amk.fi/opintojaksot/0303011/1146161367915/1146161783414/1146163048742/1146163155917.html 3/3