Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Sun Assessment Exam Question

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
# 15. There are two tables in a database, Celery and Carrot. Celery contains a foreign key to Carrot. Each table has a primary key, and there are no other constraints on the tables. No descriptors are used, and in the following options each scenario depicts all the mapping information pertaining to the relationship. Which entities accurately model this database scenario?
# @Entity Celery {
# /* ... */
# }
# @Entity Carrot {
# @ManyToOne
# Celery celery;
# /* ... */
# }
#
# @Entity Celery {
# @ManyToOne
# Carrot carrot;
# /* ... */
# }
# @Entity Carrot {
# /* ... */
# }
#
# @Entity Celery {
# @OneToOne
# Carrot carrot;
# /* ... */
# }
# @Entity Carrot {
# /* ... */
# }
#
# @Entity Celery {
# /* ... */
# }
# @Entity Carrot {
# @OneToOne
# Carrot carrot;
# /* ... */
# }


the correct answer is 2. But why can't the 3rd answer is possible ?
 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because the questions says that apart from the foreign key no other constaints exist. @OneToOne used like this used the defaults that are described in JPA specs, which has a unique constraint on the FK.
Cheers.
 
Of course, I found a very beautiful couch. Definitely. 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
    Bookmark Topic Watch Topic
  • New Topic