BA Prince the B.A. Subscribe

Home / Visio for Business Analysts

Primary Key vs Foreign Key, Explained on an ER Diagram in Visio

Primary Key vs Foreign Key, Explained on an ER Diagram in Visio

Watch on YouTube Subscribe

A primary key makes each row unique. A foreign key points to a row in another table. Learn the difference, and how foreign keys create the relationships in a crow's foot ER diagram, drawn in Visio.

Step by step

  1. Primary vs foreign key. Primary key and foreign key. Every business analyst hears these words in data meetings. Let's make them simple, with a small ER diagram in Visio.
  2. Crow's Foot stencil. I'm using the Crow's Foot Database Notation stencil.
  3. Primary key. Here's a customer entity. The first row is the primary key, customer ID. No two customers can ever share it. Notice the key icon on that row. A primary key is unique, never empty, and it never changes, so don't use something like an email address.
  4. Foreign key. Now an order entity, with its own primary key, order ID. Look at the last row. Customer ID again. That's a foreign key. It's a copy of another entity's primary key, and it says which customer placed this order.
  5. The relationship. The foreign key is what creates the relationship. Connect customer to order. One customer places zero or many orders.
  6. The many side. Notice where the foreign key lives. Always on the many side, the end with the crow's foot.
  7. Practice. One more. Each order can be shipped in several parcels. Add a shipment entity. Where does the foreign key go? On the many side, in shipment. Order ID. Connect them. One order has zero or many shipments.
  8. Done. Click away to see the finished model.
  9. The rule. So, a primary key identifies a row in its own table. A foreign key points to a row in another table, and it always sits on the many side of the relationship.

More in Visio for Business Analysts