Home » Java » JAVA Inheritance + Postgresql with json type

JAVA Inheritance + Postgresql with json type

Posted by: admin October 29, 2018 Leave a comment


I have an inheritance in JAVA, and our DBA suggested me to create one single table for all the children (like one single table strategy) but creating a json datatype with all the specific information.
Is this a good practice?

I’ll give an example, Having this three tables:

Image: thumbnailId long,
Video: duration int,
Media: id, name, description, type

Move to only one table:
Media: id, name, description, type, extra_fields

Where extra fields in the case of an image it should store thumbnail, an in the case of a video it should store duration as a json.


1- Is this a good idea?

2- Is this easy to implement in JAVA+Spring?