This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
on his book "Spring Persistence with Hibernate" Ahmad Reza Seddighi discusses alternatives to mapping inheritance hierarchy in Hibernate (pages 102-103). On the example we have Person, Student and Teacher entities. Student and Teacher extend Person. On the example Ahmad is demonstrating "One table for each concrete class" solution for the mapping inheritance problem. Now Ahmad rises question where Address entity is added to schema. This is excat quote:
If Address has a many-to-one relationship with Person (more than one person may have the same address), then the ADDRESS table should provide a foreign key reference to all PERSON, STUDENT, and TEACHER tables, in order to establish database-level relationship, but this is not possible.
I'm confused why is that not possible. Why it would be impossible to have, lets-say "AddessID", column/foreign key for PERSON,STUDENT and TEACHER tables?
With the example they suggest the multiplicity of the association is reversed. An address_id field on person for example means one address can be used by zero or more persons, and a person can have one address (or zero if the fk is nullable) . A person_id on address means a person can have many addresses, though an address itself can only be used by one person.
I think you are misunderstanding what is meant by many-to-one. Cardinality is described as the relationship from one entity to another, so many-to-one is many addresses to one person. That is not possible with an address id defining the relationship on the person table. However (like I said) the reverse is.