This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Two identical entities with similar attributes.

 
Ranch Hand
Posts: 230
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I heard a technical scenario where 2 entities having same attributes. A Boy and Girl Entity with Name, Age and DOB. How this can be formed as single entity so that fields are not repetitive ? Please share any idea. I'm also keen to find the right solution through studies. But your ideas may also help. Thanks.

Regards,
Mohammed Sardar
 
Saloon Keeper
Posts: 11219
244
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ehh, how about a 'person' entity with a 'gender' field?
 
Mohammed Sardar.
Ranch Hand
Posts: 230
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Ehh, how about a 'person' entity with a 'gender' field?


Thanks, so "Gender" as @Embedded you mean ? Can you elaborate please ?
 
Stephan van Hulst
Saloon Keeper
Posts: 11219
244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that Gender would be so complex to warrant an embeddable type. Just use an enum for Gender and you can annotate the gender field with @Enumerated in your Person entity.
 
Mohammed Sardar.
Ranch Hand
Posts: 230
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:I don't think that Gender would be so complex to warrant an embeddable type. Just use an enum for Gender and you can annotate the gender field with @Enumerated in your Person entity.


Stephan, by your idea what I understand is change to the db design of table structure itself. Instead having two tables (Boy and Girl) have one table with the name PERSON with attributes(NAME, AGE, DOB, GENDER(ENUM)) and represent the above Person table as a single Entity. Am I on track to get the above ?

Thanks & Regards.
 
Stephan van Hulst
Saloon Keeper
Posts: 11219
244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, although I don't know why you would want to have an age field if you already have a date of birth field.
 
Mohammed Sardar.
Ranch Hand
Posts: 230
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Yes, although I don't know why you would want to have an age field if you already have a date of birth field.



True, may be Edit button was disabled !!!
 
I brought this back from the farm where they grow the tiny ads:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!