Hi guys, could you help me with the following question? I am confused by B and C. I think there is nothing wrong with C, regarding syntax/restriction/specification. The only reason we should choose B instead of C ,is that B makes more sense in reallife ,right? Or have i mistaken ?Please correct me if i was wrong. Thanks in advance!
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?
Can you give me some example where I use "other constraint" so I can use OneToOne ??
Joined: Jun 28, 2007
For answer C to be correct, it was mandatory that the foreign key had a unique constraint on it.
Hi Satya, I haven't found the unique restriction stated in spec, and I haven't found it in generated sql(Container is JBoss AS 4.2.1.GA)...So I am still a little confused... But anyway,thanks for your help!It is the best answer for me now
Joined: Jan 01, 2007
Quoting from persistence spec 22.214.171.124
Bidirectional OneToOne Relationships Assuming that: Entity A references a single instance of Entity B. Entity B references a single instance of Entity A. Entity A is specified as the owner of the relationship. The following mapping defaults apply: Entity A is mapped to a table named A. Entity B is mapped to a table named B. Table A contains a foreign key to table B. The foreign key column name is formed as the concatenation of the following: the name of the relationship property or field of entity A; "_"; the name of the primary key column in table B. The foreign key column has the same type as the primary key of table B and there is a unique key constraint on it.