| Author |
Sun Assessment Exam Question
|
Amandeep Singh
Ranch Hand
Joined: Jul 17, 2008
Posts: 832
|
|
# 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 ?
|
SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
|
 |
Raf Szczypiorski
Ranch Hand
Joined: Aug 21, 2008
Posts: 383
|
|
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.
|
 |
 |
|
|
subject: Sun Assessment Exam Question
|
|
|