An important issue in programming is the Object-Relational Mismatch, but I have not seen any good explanations that use familiar terms. I came up with one involving a Family Tree application.
The idea is to store data rows that include name information and foreign keys to both parents and a spouse. (Can also store useful info like birth date, birthplace, gender and so on.) This table would obviously contain reflexive relations (self-joins) on these three foreign keys. No information about the relationships such as brother, nephew, grandparent and so on can or should be stored in this table.
The application would pull in all of this data in to a tree structure, and based on who is selected as the focus person ("me" in the tree), all of the relationship titles can be 'computed' and displayed. They are me-centric and so are not part of the data, only part of who is centered in the display.
This example points out the many and very vivid differences between a data storage method and an Object-Oriented view of data:
- the data rows simply have links to parents and a spouse
- data rows cannot contain any relationship titles (brother, etc.)
- the display can show all of the titles relative to who is "me"
- changing the "me" pointer in the display relabels all the relationships
- all relationships of any generation previous and successive can label themselves in the display
This shows the differences between data in a database and objects at run-time very clearly. I have not seen this example given anywhere else. Does it explain the "Object-Relational Mismatch" in a useful way?