is there a better way to create DB table for the particular JSON data I'm trying to work with?
I'm making a basic CRUD REST app with Spring/Hibernate that handles JSON data that I got from https://jsonplaceholder.typicode.com/users
As you can see in the link, the JSON data has nested JSONs and I made them into individual Java classes named Address, Company, Geo, and User.
At this point, I'm thinking of assigning each variable in those classes into each columns of the table by using @Column annotation because I don't know how to insert nested JSON or Arrays into postgres table.
So, by result, my SQL script ends up looking rather... primitive:
create table users."user"
(
id serial
constraint user_pk
primary key,
name varchar default null,
username varchar default null,
email varchar default null,
street varchar default null,
suite varchar default null,
city varchar default null,
zipcode varchar default null,
lat varchar default null,
lng varchar default null,
phone varchar default null,
website varchar default null,
company_name varchar default null,
catch_phrase varchar default null,
bs varchar default null
);
Is there a more elegant way of creating DB table for this particular JSON data?