DIY: making tables

It is time to take another step on our journey from designing and planning to coding. Today we are going to talk about the conversion from class diagrams to database tables.

In a previous post, about UML diagrams, I explained Class diagrams briefly. To quote myself:

Class diagrams show the classes of the system (of course), their operations and attributes and the interrelations between these classes.”

There are many different methods of converting classes to tables. However today I will explain it using the ER-method. ER stands for Entity-Relationship. It is a model which can be implemented in a database, so into tables and their attributes, typically a relational database. Today we will only discuss relational databases, since they are easier than non-relational ones.

Using the ER-model we can get a graphical view of components of the project (enterprise) and how they are related. How the ER-model is displayed:

The relationships between the entities are the lines and diamonds between the rectangles. 1, M and N stand for the cardinality between the entities, or the number of the entity involved. The word in the diamond is always a verb which specifies the relationship. One faculty can teach multiple classes for example.

Now we have completed this ER-diagram it is time to convert it into tables. If you like a video-explanation, watch this. But here are the steps:

  • Convert all the entity sets to tables
  • Deal with composite and multi-value attributes by making them individual attributes
  • Represent weak entity sets as tables
  • Represent relationship sets as tables

#Mastery08

Leave a comment

Design a site like this with WordPress.com
Get started