I am just about to start implementing a database schema, which has a few tables that inherit from another table. Some of the parent tables can be concrete and others need to be abstract since they are of no use on their own. A couple of the concrete tables also have one or many to many relationships based on the id which is auto generated in the abstract table. In the database schema, this has been modelled such that the relationship is from the concrete classes. However, since I am in a position to change the schema if need be, should the relationship be from the abstract table instead? If it can be from the concrete table how do I refer to the parent class in the relationship annotation in the child class? i.e. @OneToMany(mappedBy="ParentClass.id")
Is this a problem, or because ChildClass extends ParentClass will it be happy with just being supplied mappedBy="id")?
The same question goes for some concrete tables being extended - in some situations the extension is necessary because the extra data is required. Therefore I don't want to put the relationships on the parent table in this instance because there might not actually be a relationship there.
It's late, so please let me know if this doesn't make sense and I will re-word it if needed.
"Twenty years from now you will be more disappointed by the things you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover." - Mark Twain