How to Enforce Referential Integrity in Access Many-to-Many Relationships
Question details
The user needs to enforce referential integrity in a many-to-many relationship between tables (e.g., workshops and participants) in Microsoft Access.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Setting up table relationships and ensuring data consistency across linked tables.
- Observed behavior
- The user wants to prevent orphan records and maintain accurate links between records in a many-to-many database schema.
Before modifying table relationships, ensure all tables are closed and that the primary key and foreign key fields share the exact same data type.
Create a Junction Table and Enforce Referential Integrity
Use a junction table to resolve the many-to-many relationship into two one-to-many relationships, which allows referential integrity to be enforced.
Relational databases cannot directly enforce integrity on a many-to-many relationship. You must use a third table, known as a junction table, to act as a bridge. This breaks the relationship down into two manageable one-to-many links.
In Access, go to the Create tab and select Table Design. Add two foreign key fields (e.g., WorkshopID and ParticipantID) that match the data types of the primary keys in your main tables.
Select both foreign key fields, right-click, and choose 'Primary Key' to create a composite primary key for the junction table. Save and close the table.
Navigate to the Database Tools tab and click 'Relationships'. Add your two main tables and the new junction table to the workspace.
Click and drag the primary key from the first main table (e.g., Workshops) to the corresponding foreign key in the junction table.
In the Edit Relationships dialog box that appears, check the box for 'Enforce Referential Integrity' and click 'Create'. Repeat this process by dragging the primary key from your second main table to the junction table.

Looking for a Lightweight Alternative to Microsoft Office?
While Microsoft Access handles complex relational databases, for everyday data tracking, analysis, and reporting, WPS Spreadsheet offers a lightweight, completely free, and highly compatible alternative. WPS Office seamlessly integrates Writer, Spreadsheet, Presentation, and PDF tools into one application.
- 1. Download WPS Office: Visit the official WPS website and click 'Download WPS Office Free' to get the installer for your operating system.
- 2. Install the Suite: Run the downloaded installer file and follow the simple on-screen instructions to set up WPS Office on your device.
- 3. Open Your Data Files: Launch WPS Spreadsheet and easily open your exported Excel (.xlsx) or CSV database extracts to continue analyzing your records.

Frequently Asked Questions
Why can't I enforce referential integrity directly between two tables in a many-to-many relationship?
Relational databases like Access require a junction table to break down a many-to-many relationship into two one-to-many relationships. Referential integrity can only be enforced on the one-to-many level to ensure a child record always has a valid parent record.
What happens if the data types of the primary and foreign keys don't match?
Access will prevent you from creating the relationship or enforcing referential integrity. Ensure both fields share the exact same data type. For example, if using an AutoNumber primary key, the corresponding foreign key must be a Number data type.
Will enforcing referential integrity delete my existing data?
No, but if you have existing orphan records in the junction table (foreign keys that do not exist in the primary tables), Access will throw an error and refuse to enforce referential integrity until those invalid records are cleaned up or deleted.




