ER Diagram and their Relational Schema

ER Diagram is a conceptual design of a database. This is the first step to designing a database where we identity all the entities and the relationships in a database. The entities are represented by rectangles and the relationships are represented by diamonds. Below is an example of an ER Diagram for a library:

The above conceptual design of a database can be further materialized into something called Relational Schema where we convert all entities and relationships into tables. Entities can be easily converted into tables, but how do we convert relationships into tables? This is done by identifying primary keys in entities. To refresh your memory, primary keys are unique in a table( or entity). Once the primary keys are identified, the relationships can now be converted into tables by simply using the primary keys of the two entities the relationship connects to. For clarity, the Relational Schema of the above ER Diagram is shown below (Note: the primary keys that are starred in ER Diagram are bold faced in the below Relational Diagram).

When creating the table for relation entities, the keys identified in the above diagram will be used as foreign keys referencing the table where they are primary represented as primary keys

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.