Issue
I'm making Spring Boot and Thymeleaf web app and I want to ask you for advice about persisting addresses in the database. My question is how would you store the addresses for these two entities.
I have a real estate
and user
entity.
Should I put in both entities fields state
, city
, street
, etc, or make a new entity Address
where I should store address
from real estate
and current address
from user
.
And is it ok to type addresses manually or is there some free API with country and addresses I can use? Do you have some examples?
Solution
This is opinion based. IMHO, you could create an Address
entity, and as such your RealEstate and User could have @OneToOne
relation to Address
.
To retrieve a list of Countries, String[] countryCodes = Locale.getISOCountries();
However in terms of Addresses, this is country/region specific, and it would need to be entered by the User.
Answered By - SMA
Answer Checked By - Willingham (JavaFixing Volunteer)