These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Soft Delete
PostPosted: Mon Dec 15, 2008 10:05 am 
Newbie

Joined: Mon Dec 15, 2008 9:50 am
Posts: 2
Hi !

I have a requirement for soft delete. Following is the table structure:

Student
-ID
-FirstName
-LastName
-Grade
-DeleteFlag

Problem: How can i have constraints such that i can create only UNIQUE(FirstName,LastName) along with the soft delete approach.


Top
 Profile  
 
 Post subject: Re: Soft Delete
PostPosted: Mon Dec 15, 2008 9:31 pm 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
paull.williams wrote:
Hi !

I have a requirement for soft delete. Following is the table structure:

Student
-ID
-FirstName
-LastName
-Grade
-DeleteFlag

Problem: How can i have constraints such that i can create only UNIQUE(FirstName,LastName) along with the soft delete approach.


I think you can not have a constraint for this case. Suppose you add unique for firstName, lastName, and deleteFlag, you can only delete once.


Top
 Profile  
 
 Post subject: Don't us a flag to mark soft deletes - use a timestamp
PostPosted: Thu Jan 15, 2009 6:49 pm 
Newbie

Joined: Thu Jan 15, 2009 6:44 pm
Posts: 1
If you use a timestamp instead of a simple flag you can easily have a unique constraint as you describe.

This has the added advantage of letting you know when something was 'deleted' and simplifies housekeeping tasks such as physically deleting all records that were soft deleted over X months ago - which may be useful if your database is going to get large.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.