Search code examples
keyumlentity-relationship

how to show primary keys which include foreign keys in ERD?


When ER diagrams are draw, they don't include the foreign keys in the entity types. However, the primary keys of certain entity types are composed for multiple attributes including the foreign keys. The standard way to indicated that an attribute (or set of attributes) is used as the primary key is by underlining them in the ER diagram.. but how do I show that a foreign key is part of a composite primary key if the foreign key isn't show in the ER diagram? I'm using the UML notation for ER diagrams.


Solution

  • You don't. It's a primary key in another table, so the relationship drawn between entities is enough to show that it is a foreign key in the other table.

    To show a composite primary key underline both attributes or alternatively make an attribute with 2 attributes leading out of it, underline the first attribute(call this what you want) and this shows that the two "sub" attributes form the primary key. Remember whether they are foreign or not is irrelevant in terms of drawing the erd.

    Hope this helps.