• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

HFE p.434

 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
question 12: why is box D. "SELECT OBJECT(o) FROM Order o checked" ?
Normally, this query means "finds all orders". I understand that it may also mean "orders with lineItems" because conceptually, what does mean an order without lineitems? Nothing interesting...
But in the same book, p.418, we have also an example of one-to-many relationship between a Director(1) and Movies(n), and here, the query:

SELECT DISTINCT OBJECT (d)
FROM DirectorSchema d
WHERE d.movies IS EMPTY


makes apperently sense to the authors: "this query returns only those directors who have not madde any movies" or "Just show me the losers who haven't made any movies..."
Can't we imagine also that it may exist "loser orders which haven't any lineitems?".
More seriously, it seems that the relationship one-to-many doesn't necessary imply a conclusion about this kind of question. Because it tells us only about maximal cardinality and not minimal cardinality.
So the relationship between a Director and movies may be of type (1,1) -> (0,n) whereas relationship between an order and lineitems would be rather of type (1,1) -> (1,n).
Which means also that a Director without movies is conceptually conceivable whereas an Order without Lineitems is not.
Which means also that query

SELECT DISTINCT OBJECT (d) (or (o))
FROM DirectorSchema d (or Order o)


doesn't mean exactly the same thing...
Regards,
Cyril.
 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cyril:
The way the question is worded, it can be inferred that it is possible in this case to have orders without line items, not that it makes sense. Therefore
SELECT OBJECT(o)
FROM Order o
would return all orders with or without line items.
The correct query should have a WHERE clause as follows:
SELECT OBJECT(o)
FROM Order o
WHERE lineitems IS NOT EMPTY
I recently posted to a thread discussing the same issue. You can find it at https://coderanch.com/t/158551/java-EJB-SCBCD/certification/EJBQL-HFE-page
Hope this helps.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic