Q

Data model for foreign key referencing primary key

Table A has a composite primary key. Table B has a foreign key referencing one of the primary keys of the composite primary key of Table A. We've modeled this in our RDBMS, but our ORM tool, Hibernate, does not allow this kind of model. Is there any alternative data model to implement this?

Table A has a composite primary key. Table B has a foreign key referencing one of the primary keys of the composite primary key of Table A. We've modeled this in our RDBMS, but our ORM tool, Hibernate, does not allow this kind of model. Is there any alternative data model to implement this?

You can implement your model in SQL*Plus without using any tool. Simply create the table and constraints.

That being said, if I had a FK constraint pointing to only a portion of a composite primary key, I would probably rethink my design. Are you sure that your design is correct and conforms to the Third Normal Form (3NF)? If you are not 3NF, then you run the risk of introducing data anomolies.

This was last published in May 2006

Dig Deeper on Oracle database design and architecture

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close