Roles in Microsoft Access Databases

Articles Index

Course Listing

Free Catalog

Request Information

What's New

View related PowerPoint slides on Slideshare

Glossary of Database Terms

 

Page 1 | Page 2 | About

Right Way (one table per role)

Remove the referring physician link to the doctors table. Add the doctors table a second time. Then link the referring physician foreign key to the the second doctors table. The underlying query processor will actually treat this query as if there were three separate table involved. Doctors_1 is technically an alias for the doctors table.

Correct query with roles

Results

We now get each admissions record with the admitting and referring physicians.

Correct query results

Referential Integrity

This solution to using roles in a Microsoft Access database will preserve referential integrity if set. It will not be possible to enter an admissions record that does not refer to a valid entry in the doctors table. Nor will you be able to delete doctors that have patients assigned either as a referring or admitting physician unless you cascade deletes.

Concluding Thoughts

You can use the technique in this article if you have entities (tables) that play multiple roles and you wish to enforce referential integrity. If you do not care to enforce referential integrity then you probably won't need to create a relationship design. But you will still need to add the table multiple times in the query designer as I have shown.

Dan D'Urso
Laguna Niguel, CA 92677
July 2012
articles at dhdurso dot org

HTML Comment Box is loading comments...


Submit the form below to be notified of new articles or other Microsoft Access resources made available...

Receive course announcements and news. Sign Up Today!





Email Marketing by VerticalResponse

Learn more about our Microsoft Access courses..

View SQL course catalog.

 


Please send comments and suggestions to WebMaster at dhdurso.org

Copyright 2017 D.H.D'Urso & Associates
Laguna Niguel, Orange Coutny, California

 Articles Index | Close Window | Next| Top