--Originally published at Newbie Programmer
To convert classes diagrams to database tables it’s a process that the modeling language used for doing the class diagram help us to make this transition because we know how to do class diagrams in UML, and if you compare a database table to a class diagram they are quite similar because you have the name of the class or the table, the attributes and type of variable they use, and the relationship between tables or classes, but you need to add some concepts for converting the class diagram design to a table.
First the attributes are stored in columns in the database tables, and you need to have keys, the keys are attributes that are unique in that table and you must have that key to have the attributes stored in a table, for example if we have a table with name of customers we can’t have a customer without their name so the primary key is name of the person, also we have foreign keys, this attributes are primary keys of other tables, for example we have our list of workers that they have an id from the government, this id can be extracted from another table that help us to no have the same data in two different tables to avoid ambiguity.
To show the relationship between tables is quite similar to the class diagram because we have the concept of multiplicity that show us if we need another class or table created to another table to exist, for example we can’t have a school without teachers and students, and this are represented in lines in which we have verbs, for example works for, have, controls, etc.
This image is a database of an order, we can see that the table Orders we have primary key named orderID, and in the Products table the primary key is productID, in the other hand the table OrderDetails have two keys that are foreign keys because this are stored in another tables, and in the multiplicity we can see that Orders can have one to many items in OrderDetails, and OrderDetails belong to one Order, in the other case Products can appear many times in an OrderDetails, but OrderDetails its specified for one Products.