Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8799947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:27:33+00:00 2026-06-14T00:27:33+00:00

I have a Logs table in my database where I’m storing records of user

  • 0

I have a Logs table in my database where I’m storing records of user actions. There’s a column for UserID, which is foreign-keyed to the Users table to check that the UserID exists when a log is added. However, attempting to delete a user causes a constraint failure because it leaves a UserID in the Logs table that no longer exists in the Users table. Deleting the offending rows from Logs isn’t an option, because the whole point is to have persistent records (so that we can find out who broke what, basically) so deleting all actions by that user rather defeats the purpose.

Is there a simple way to have it check the constraint when inserting new logs (to make sure the user exists at the time) but not when deleting a user? I’m accessing the DB via LINQ, so my queries are in C#, not SQL, so anything that requires that is out, but I have access to the database through MS SQL Server Management Studio, so I can do what I like with it.

EDIT for slight clarification: the value of knowing who made an action is not just in accountability; it’s useful in determining if an issue is user-specific, organisation-specific, or system-wide, which can greatly narrow down the list of possible causes. Once a user is deleted, it’s still worth keeping their actions, and it’s still useful to know which actions were by that user, for various reasons – for example, when tracking down an issue caused by one user doing a certain combination of things (eg. two actions that are fine separately but cause errors when one immediately follows another).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:27:35+00:00Added an answer on June 14, 2026 at 12:27 am

    If you really want to keep the logs, you should never fully delete the user.

    Rather than deleting the user record, change its state to indicate it is deleted, so your database still has referential integrity.

    Alternatively, switch on cascading deletes, so when you delete the user, the logs are all removed at the same time, which is another way of maintaining referential integrity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in Postgres database logs which holds the error logs with
I have one large database table of request data, much like Apache request logs,
I have a table called LOGS with the following columns: id - user -
I have the database table logs as the following: alt text http://www.freeimagehosting.net/uploads/16e974703a.jpg I would
I have a web app that logs invalid login attempts to a database table.
I have a table (Logs) in which I keep logs of what happens on
I have a table in my database which contains all of the users for
Users details are held in database table called user where I have fields username
Using MySQL, I have a simple table that logs the IP Address that users
I have an application which logs in into a webservice. I start a new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.