0

I'm working on a database and I have a table called "Users", which store the sites user information (username, email and so on). The site has a forum and if a user that has posted something on the site deletes his account, I want "Deleted user" to appear instead of the username next to the post.

I know this is possible to do with referential integrity (set default) in SQL Management Studio, but I just can't figure out how to do it. I have created a user in the table called "Deleted user" that has got UserId "1".

Thanks in advance!

holyredbeard
  • 19,619
  • 32
  • 105
  • 171
  • why not add flag to user table `deleted` set it to true/false and when querying user you can use `case when deleted = 1 then 'Deleted User' Else UserName End UserName` – rs. Mar 06 '12 at 18:17

1 Answers1

1

It shouldn't be up to the database to determine what a default user is or how to handle the logic around a delete. The application should say to the database, "give me user 123" and the database should say return no result or a flag saying that the user is deleted. The app would then take that information and display "Deleted user". Logic like that should be abstracted away from the data.

geekonablog
  • 319
  • 1
  • 3
  • 14