473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Best way to delete a user

Seth Schrock
2,965 Expert 2GB
Most of my databases have something to do with logging who is doing what among other things. As such, I have a table for employees with all their information and link that information to the audit record using the primary key. My issue then is what is the best way to "delete" a user when they no longer work for the company? If I actually delete the employee record, then I end up with orphaned records in the audit table.

I'm not looking for exact code or some special procedure. I'm just needing an idea for how everyone else handles this. I've used a couple of methods personally, and none get me real excited.

Things I've tried:
1) Create a "Deleted User" employee and when I want to delete a user, all their audit records get assigned to the "Deleted User" before actually deleting the employee.

2) Have an "Active" flag on the employee record so that when they quit, the flag gets unchecked and thereby removed from all available employee lists.

3) I haven't done this one, but thought about it. Instead of using the employee's primary key to create a link in the audit table, I could use the employee's name. Then when the employee's record is deleted, the name is still sitting in the audit table and the orphaned record doesn't matter.

4) Do nothing and let the list of employees keep growing.

Again, I'm not looking for specific code. Just wanting some general ideas for how to handle it.
Feb 10 '22 #1
2 16565
Niheel
2,460 Expert Mod 2GB
Seth,

Wouldn't the first option create a bit of a problem if there are multiple "Deleted User" employees and the audit records get jumbled.

The second option is seems like a better approach, but that would probably require code/query modifications to not show employees with that flag?

I like the flag approach.
Apr 15 '22 #2
zmbd
5,501 Expert Mod 4TB
I use an active flag and occasionally another related table for terms of employment ...

At my work we have an outside panel from a temporary agency, these people come and go; however, with sarbanes oxley act, we have to keep certain types of records for quite a long time but I don't want the inactive temporaries to show up in the dropdowns etc... so I use the flag to indicate status (not exactly normalized as you'll see); however, I may need them for aggregate reports for the times that they were active on panel hence the second table {PK_TmpPnlMemActv}{FK_TmpPnlMem}{StartActiveDate}{ EndActiveDate} - In a perfect world, I would use only this second table, pull up all record where {EndActiveDatae} Is Null pull the innerjoin between the two tables, return matching records ... I got lazy, over a dozen dropdowns, I just filter on the active flag.
Apr 16 '22 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Doron | last post by:
Hi all I need to Delete a user from a database open with user that do not have permision to do so I have created a function that will create new workspace with UserName and Password of one that...
1
by: Jordan | last post by:
I'm converting a section of our website into the .NET framework (the rest will follow sooner or later). I'd certainly like to maintain all the dynamic capabilities as well as implement some new...
0
by: Rocky | last post by:
How can list and delete user profiles on a remote machine that is in AD via a asp.net webform using vb.net?
3
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
When using the Web Site Administration Tool, I get the following error when trying to delete a user in a web application I configured to use membership, roles, and profiles: "An error was...
2
by: VB Programmer | last post by:
Using the membership/roles feature in ASP.NET 2.0. What is the best, cleanest way to "delete" a user? Thanks!
3
by: at_the_gonq | last post by:
Hello, I am hoping to get some guidance on the following scenerio: I have a password protected site where users have various permissions. Are sessions the best way of storing the user's id? ...
0
by: shaikhcons | last post by:
I am working on a program that will delete a user profile from server 2003, I can use delprof in a cmd but this is a very basic way to clear my server with old unwanted user profile. I am looking...
15
by: vishal prada | last post by:
<html> <body> <table width="50%" border="1" rules=ALL> <tr><th> Username</th><th>Access Level</th><th>Delete</th></tr> <%@ page language="java" import="java.sql.*" %> ...
1
by: Anbu123789 | last post by:
I user identity application from which I want to create User, create Group, Delete User, Delete Group and Reset Password in OpenLDAP through C# code. Please reply
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.