Others

How to Change Primary and Foreign Key Symbols in Visio ER Diagrams

Huda QurayshiHuda Qurayshi Nov 2, 2026 869 views

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.

How to Change Primary and Foreign Key Symbols in Visio ER Diagrams
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.
Before you start

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.

Solution 1Recommended

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.

1
Show the Document 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.

2
Locate the Attribute Master Shape

In the Document Stencil pane, locate the master shape responsible for the database attribute (often named 'Attribute' or 'Primary Key').

3
Open the Master Shape for Editing

Right-click the master shape, hover over 'Edit Master', and select 'Edit Master Shape'. This will open the shape in a new editing window.

4
Customize the Key Symbol

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.

5
Save and Apply Changes

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.

Edit the Master Shape in the Document Stencil
Global Document Update: Your ER diagram will now automatically display the customized black box with white text for all key attributes, maintaining consistent notation without manually editing each shape.
Free Microsoft Office alternative

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. 1. Launch WPS Office: Open WPS Office and click on 'New' to start a new project.
  2. 2. Access Diagram Tools: Create a new document or presentation, then navigate to the 'Insert' tab to find Shapes and Chart drawing tools.
  3. 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.
Built-in flowchart and drawing tools perfect for database schema designHigh compatibility with Microsoft Office file formatsFree, lightweight, and easy to navigate with a familiar interfaceRich library of customizable shapes and templates
microsoft office alternative - wps office

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.