How to Change Primary and Foreign Key Symbols in Visio ER Diagrams
Question details
The user wants to replace the default primary key and foreign key icons in Visio's Crow's Foot Database Notation with customized black boxes containing white text.

- Product
- Microsoft Visio 2019
- Device & OS
- not provided
- Scenario
- Customizing the visual notation symbols in an Entity-Relationship (ER) diagram.
- Observed behavior
- By default, Visio displays standard key icons for primary and foreign keys. The user wants to change this representation across the document to a specific text-based box format.
Ensure your Document Stencil is visible in the Visio workspace, as you will need to modify the master shapes that govern the appearance of attributes throughout your current diagram.
Edit the Master Shape in the Document Stencil
Modifying the master shape in the Document Stencil ensures that all current and future instances of the primary and foreign key symbols in your diagram update automatically.
Editing the master shape is the most efficient way to change the visual representation of database notations across an entire Visio document. Note that this change only applies to the current document; applying it to other documents requires saving the modified shape to a custom stencil.
Navigate to the View tab on the Visio ribbon. Click on Task Panes and select 'Document Stencil' from the dropdown menu to open the stencil panel.
In the Document Stencil pane, locate the master shape responsible for the database attribute (often named 'Attribute' or 'Primary Key').
Right-click the master shape, hover over 'Edit Master', and select 'Edit Master Shape'. This will open the shape in a new editing window.
Select the default key icon within the shape and delete or hide it. Use the drawing tools to insert a small rectangle, fill it with black color, and add white text (such as 'PK' or 'FK') inside the box.
Close the master shape editing window. A prompt will appear asking if you want to update the shape and all of its instances. Click 'Yes' to apply the customized black box to all primary and foreign keys in your document.

Create Professional ER Diagrams with WPS Office
Looking for a cost-effective and highly compatible way to design database schemas? WPS Office offers powerful built-in drawing and diagramming features that make creating Entity-Relationship diagrams incredibly simple. Enjoy a lightweight, free alternative to Microsoft Office that doesn't require complex master shape editing.
- 1. Launch WPS Office: Open WPS Office and click on 'New' to start a new project.
- 2. Access Diagram Tools: Create a new document or presentation, then navigate to the 'Insert' tab to find Shapes and Chart drawing tools.
- 3. Build Your ER Diagram: Use the intuitive drag-and-drop shapes to construct your database schema, easily adding custom text boxes for Primary and Foreign Keys.

Frequently Asked Questions
Will customizing the master shape affect how the shape routes connectors in the ER diagram?
No, editing the visual elements of the master shape (like replacing the icon with a text box) does not affect the connector connection points or the underlying logic. The entity shapes will still move, and relationships will route correctly.
How do I apply my customized primary key symbols to other Visio documents?
Master shape modifications made in the Document Stencil only apply to that specific file. To reuse your customized primary and foreign key symbols, you need to drag the modified master shape into a new, custom stencil file (.vssx) and load that stencil whenever you create a new document.
Why can't I just change the key icon directly on the drawing canvas?
In Visio's Crow's Foot Database Notation, the key symbols are grouped sub-shapes tied to the master shape's properties and behaviors. Changing them individually on the canvas is often locked to maintain formatting consistency. Editing the master in the Document Stencil safely overrides this behavior globally.




