Keys in ER models are transformed into constraints in a DDL model. These are the rules for key transformations into DDL constraints as follows.
- The Primary key of the entity in the ER model is transformed into a primary key constraint in the SQL model.
- The Alternative keys of the entities in the ER model are transformed into unique constraints in the SQL model.
- The Inversion entries of the entities in the ER model are transformed into indexes in the SQL model.
- If key or entry in ER model has a name (identifier tag), this information is preserved in the SQL model. The corresponding key / index will also have a name in the SQL model.
Let's review an example of key modeling, which has been described in Key modeling. After the transformation, the three entities of the ER model are transformed into the three tables of the SQL model respectively.