Hi,
Please explain me this -
From chapter 1 page 17..
It isn’t possible to determine the multiplicity of a unidirectional association by looking only at the Java classes.
Then the author says ....
Java associations can have many-to-many multiplicity.
For example, the classes could look like this:
public class User {
private Set billingDetails;
...
}
public class BillingDetails {
private Set users;
...
}
Does the second sentence explains what the first sentence has to say, if yes...how?
Or simply put...why the author says what he says in the first sentence
Also: Please see the questions inline following the bolds
For example, if you need to retrieve a User and aren’t interested in the
user’s billing information, you can write this simple query:
select * from USERS u where u.USER_ID = 123
On the other hand, if you need to retrieve a User and then subsequently visit each
of the associated BillingDetails instances (let’s say, to list all the user’s credit
cards), you write a different query:
select *
from USERS u
left outer join BILLING_DETAILS bd on bd.USER_ID = u.USER_ID
where u.USER_ID = 123
As you can see, to efficiently use joins you need to know what portion of the object network {in our example what would be that portion?}you plan to access when you retrieve the initial {what is the significance of this word?} User—this is before you start navigating the object network!{the object n/w formed in memory by executing the above query or the resulting java object n/w?}
On the other hand, any object persistence solution provides functionality for fetching the data of associated objects only when the object is first accessed. However, this piecemeal style of data access is fundamentally inefficient in the context of a relational database, because it requires executing one statement for each node or collection of the object network that is accessed. This is the dreaded n+1 selects problem.
This mismatch in the way you access objects in Java and in a relational database is perhaps the single most common source of performance problems in Java applications. {could you give an example to explain how the mismatch leads to this performance problem?} There is a natural tension between too many selects and too big selects, which retrieve unnecessary information into memory. {could you put it in other words, I mean if both are bad what is the tension?}
Thanks,
Ammar
|