MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old February 9th, 2004, 07:40 PM
chichian chichian is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Las Vegas
Posts: 12 chichian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 49 m 17 sec
Reputation Power: 0
Keep track of references to table entries/rows

Hello, I am new to db's, so I don't know if this is just common knowledge or what...

I want to design my tables so that maintenance/pruning will be easy in the future. The issue is that most fields have many-to-many relationships, and I do not want to delete rows that have references to them.

So, I am trying to figure out an efficient way to keep track of the number of references an entry in a table has so that on a regular basis I may delete all entries in all tables with no references to them. (Does this make any sense at all???).

Is there an efficient way to do this? I was thinking of adding a column in each table for the number of references the entry had to it. This seems like a safe way to do it, but it also seems like it adds A LOT OF OVERHEAD. Every time an insert is done (into any table that references other tables), I must update other table(s) entry(ies) to increment the number. Of course, also, whenever a delete is made, I have to update all referenced entries in all concerned tables to decrement their corresponding counts (number of refs).

I had been looking at the FOREIGN KEY constraint, and it seems that all I have found is that when the primary key it is linked to is deleted, then I can set all referencing foreign keys to delete as well. This is the opposite of what I want to do though (I want to delete entries once no other entries from other tables reference it).

Please help! There has to be a better way to do this. I am sorry if I didn't explain this very well. Oh yeah, I am using MS SQL Server 2000.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Keep track of references to table entries/rows


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway