Solved

Foreign Key or no Foreign Key

Posted on 2011-03-16
3
323 Views
Last Modified: 2012-05-11
I am setting up a database where I will need to allow the user to delete records in a table that relates to a second one in a one to many relationship.  However, the table that is the 'one' table  holds data that can be deleted but the client wants to be able to save the 'many' table records for historical reporting.  Settiing up a Foreign Key in the 'many' table will cause an error when the record in the 'one' table is deleted.  I have tried to set up the tables different ways to avoid this relationship but it is what it is.  The only solution I know is to handle the relationship as needed in code but is there a better way?  
0
Comment
Question by:McGurk1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
AriMc earned 500 total points
ID: 35150799
You could set the referencing column value to null before deleting the row it refers to.

0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 35150848
Generally speaking a historical table will not require references to any external tables and doesn't need foreign keys.
0
 

Author Comment

by:McGurk1
ID: 35150890
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question