Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

HF Page434 Q. 12

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
The Q.12 is
Given CMP beans CustomerBean, OrderBean and LineItemsBean with the following relationships:

CustomerBean (1) <--> OrderBean (n)
OrderBean(1) <--> LineItemsBean(n)

Which will return all orders that have line items? (Choose all that apply.)
A. SELECT DISTINCT o FROM Order o, IN (o.lineItems)li
B. SELECT DISTINCT OBJECT(O) FROM Order o, IN(o.lineItems) li
C. SELECT OBJECT(o) FROM Order o WHERE o.lineItems = 0
D. SELECT OBJECT(o) FROM Order o

The correct answers are listed as B and D.

B is fine. But how the answer D is TRUE?

Could anybody please explain?
Thanks.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it's the wording of the question.
It says "will return all orders that have line items" (didn't say only).

The set "all orders that have line items" is definitely
a subset of the resultset of Query D, which contains all orders.
That's why D is correct too.

This is what I think.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually can someone explain why Option B is correct? My naive understanding that the syntax DISTINCT would only return one object and not a collection i.e. "all orders with lineitems".
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DISTINCT implies duplicates will be avoided - it can still return a collection of unique records staisfying the QL statement.
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic