This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I need a bit of explanation about bidirectional relation between two entity beans.

 
raminaa niilian
Ranch Hand
Posts: 551
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
thank you for reading my post.
Can some one please tell me what could be possible tables and table relation for following code?

House.java:




Student.java




thanks
 
Tong Wang
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you are asking about the SQL table structure for storing these entity beans. As for the SQL part, there is no difference between bidirectional and unidirectional relations. You will have the same primary key/foreign key constraint in the tables, or you will have the same join table.

In other words, you will have primary keys in both tables and a foreign key in the many-side table that refers to the primary key of the one-side table.

Or, you will have a join table with two foreign key columns: one referring the primary key of the one-side table, the other referring the primary key of the many-side table.

Hope this helps.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
House table has a house_id PK

Student table has a student_id PK and a house_id Foreign Key (FK)

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic