First let me say I am using MySQL (not transactional) and that this can't be changed. Also, I have simplified the tables here for brevity and clarity.
In this example a 'Lesson' is comprised of it's internal attributes and an external attributes with it's own attributes 'Readings'. 'Readings' has it's own key dependent attributes and three distinct external attributes (the reading sources).
I want to avoid the polymorphic association that arrises here but am unable to wrap my head around it. In this example 'sourceId' in table 'Reading' would contain the id from one of three tables "ExternalURL", "InternalURL" and "Book". Also, the field "polytable" would contain the table name that the aforementioned "id" came from.
Can someone take a moment to please explain how to resolve this maintaining RI or is it possible that in the interest of efficiency that it should be left?
Thank you for your time and consideration,
Tim
-------------
| ExternalURL |
-------------
| id |
| badlink |
| url |
| |
| |
-------------
|
|
|
/ \
------------ ------------- -------------
| Lesson |-------<| Reading |>-------| InternalURL |
------------ ------------- -------------
| id | | id | | id |
| label | | lessonId | | url |
| summary | | sourceId | | |
| lessonOrder| | polytable | | |
| active | | label | | |
------------ ------------- -------------
\ /
|
|
------------
| Book |
------------
| id |
| label |
| summary |
| lessonOrder|
| active |
------------