0

I have different entities in my model and more than one needs an Address, is there any way to do this without having tables with duplicate information? E.g. a model that has a User and an EnglishClass entity, both need an Address with same data, as city, country, state, etc. Is there a way to have this Address information only in one place (without having AddressUser and AddressEncglisClass entity) and without having an Address table that has both User and EnglishClass objects? I want to avoid this to avoid having null values.

Molly
  • 297
  • 1
  • 5
  • 16
  • Put the foreign key in the User and EnglishClass entities. That said, I do not recommend it since probably you only sheldom find reused addresses, so it is not worth the effort of searching for it in the database. Let the user type it each time. – SJuan76 Apr 24 '13 at 21:56
  • And by the way, if you are using JPA don't talk in terms of foreigns keys. Just have `User` have an attribute of type `Address`. – SJuan76 Apr 24 '13 at 21:58

0 Answers0