• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JPA Entity Relationships Newbie Questions

 
Greenhorn
Posts: 8
MySQL Database Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,

This is my first post so I hope I am going about this the right way. I am working on my first JPA project ever so this may seem like some very basic questions but please bear with me.

My work has me putting together a database for all of the awards we have given out over the last 40 years to our faculty and students. My database structure looks kind of like the picture I have attached to this post. We have about 850 award instances of the 30 or so awards we give out each year. They have been given to about 500 different people and some people have received an award multiple times or multiple awards.

I understand that my Award Instances table has a many to one relationship with each of the other tables but how do I show that in my entities?? Do I treat my Awards Instances table as one big join table??

I've looked at lots of examples but all of them are usually just 2 tables. I'm not sure how to treat something more complex.

Thanks for any help you guys are willing to give!
Database-Relationships.jpg
[Thumbnail for Database-Relationships.jpg]
Database Jpeg
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't really see the need for the Year Awarded entity. Why not just make a date field in "Instance of Award". By the way I don't really like that name. Also the name of the entity "Award Name" is weird. Why not name it Award with a field name?

Coding a ManyToOne relationship isn't that complicated. Could you show us your code (not all but only the relevant)?
 
Calvin Hughes
Greenhorn
Posts: 8
MySQL Database Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah sorry the picture I posted was for brevity to show the general layout of the tables. Each table other than the year shows more detail and has a different naming scheme. To be honest I think I am over thinking things. I'm still studying up on how to use JPA and JPQL. Other than mapping out the relationships between tables in the entities, working with how the tables data all comes together should be in my queries right? wow I feel like that is a really dumb question.

I'll post some code when I actually have an example to show.
reply
    Bookmark Topic Watch Topic
  • New Topic