Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

many-to-many where middle table has extra fields

 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What kind of mapping will we have if we have additional fields in middle table, other than the foreign keys connecting the 2 tables?

Existing:

Student(key:studentid, column:name)
Student_courses (foreign keys studentid and courseid) <---middle table
Courses(key:courseid, column:description)

New:

Student(key:studentid, column:name)
Student_courses (foreign keys studentid and courseid, ADDITIONAL FIELDS: 2 NON-KEY FIELDS: STARTDATE AND ENDDATE) <---middle table
Courses(key:courseid, column:description)

As seen above, i added startdate and enddate, 2 strings.

Existing hibernate will be like this:



and



Will you let me know how the new one will be?

 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case you'd have an entity representing the middle table, and you'd break it down into two many-to-one relationships.
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks ill try that
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic