If you have only one table instead of two, reading will be faster because you will avoid "join". But you will use more space because you will have an extra dtype column and some empty columns.
Take an example. Here is the model (without JPA annotations):
public abstract class Like { public Long id; public String foo; } public class PostLike extends Like { public String post; } public class TopicLike extends Like { public String topic; }
You will get a Like table:
---------------------------------- |dtype | id | foo | topic | post | ---------------------------------- |post | 1 | a | NULL | p1 | |topic | 2 | b | t1 | NULL | ----------------------------------
And as you can see, for the PostLike element, you will have a NULL theme value.
But there is currently disk space if this is not a real problem.
The only drawback that I see when inheriting with a single table is the number of columns that can be huge if you have many properties, and itβs more difficult to add a new property / column to your model (if you need to apply DB Evolution).
And AFAIK, ebean only supports "unidirectional table inheritance."
source share