Converting ER Diagrams to a [[Relational Model]]
Even though ER Diagrams contain more semantic information, they are harder to turn into actual databases because some of the constraints are impossible to represent.
# Simple Entities
When you have an entitity without any relations connected to it, all you need to do is to create an entry in the schema with the given attributes.
# N:M Relation Type
With an N:M relationship, you need to create a new entry in the schema to represent that relation. Here is a more visual example:
# 1:M Relationship
In this case you just push the relationship information to the side with the * cardinality.
# 1:1 Cardinality
Same as the 1:M one, just need to pick a side to put the relation.
# Attributes Attached to Relation
When attributes are attached to a relation, you simply add another attribute to the relation.
# Weak Entity and Identifying Relationship in ER Diagrams
Since weak entities are defined using the identifying relationship, you put the relationship in the weak entity.
# Composite Attributes
You just flatten them
# Multi-Attribute
Treat the attribute as a relation and create a new relation with a cardinality of 1:N.
# Inherited Attributes and Relations
Create a single entity that contains all the attributes and relations from all types and add an extra attribute type.