Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Using OneToMany or ManyToOne . A Performance issue
Using OneToMany or ManyToOne . A Performance issue [message #646419] Thu, 23 December 2010 21:48 Go to next message
Arun Joy is currently offline Arun JoyFriend
Messages: 10
Registered: July 2010
Junior Member
I have a company entity and an employee entity

I can model it as

//Approach 1
class company
String id;
List<Employee> employees;

OR as

//Approach 2
class employee
String id;
Company company;

If i am not interested in a bidirectional relationship between the entities,

Approach 1 would produce 3 Database table like this

Table : Company


Table : Employee


Table : Company_Employee

CompanyId EmployeeId

And if I go for approach 2 I can make it with 2 tables

Table :Company


Table :Employee
Id CompanyId

Avoiding a table join means performance gain. ie, with approach 2 i get better performance at the cost of class modeling.

Is this scenario valid ? What would be your option in this context?
Please let me know
Re: Using OneToMany or ManyToOne . A Performance issue [message #647082 is a reply to message #646419] Tue, 04 January 2011 14:28 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1190
Registered: July 2009
Senior Member

This question is more a database design question, not an object modeling question. If you want a company to have a list of Employee's, this can be done regardless of there being a join table or not - ie you can use
List<Employee> employees;

List<Employee> employees;

The second option uses a foreign key "FK_COMPANY_ID" in the Employee table. So there is no cost to object modeling - other than when accessing the list, it will cause a query on the Employee table for associated Employees.

Best Regards,

Previous Topic:problems using metamodel generator in Eclipse
Next Topic:FK value setting in a ManyToOne relationship
Goto Forum:

Current Time: Thu Oct 27 11:28:19 GMT 2016

Powered by FUDForum. Page generated in 0.08200 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software