MySQL Forums
Forum List  »  Newbie

How to prevent wrong references on record deletion?
Posted by: M L
Date: February 11, 2009 06:36PM

Hello all,
I'm developing a little Ruby on Rails application using MySQL. Let's say we have two tables: hosts and events. The table hosts has the following structure:
id: primary key
hostname: server1
events_count: 1

The events table:
id: primary key
event: Reboot
hosts_id: 1

Now let's say the server1 has 1000 events. The questions are:

1) How to prevent the lost of the events information if i delete the server1 record? All i can do is warn the user on record deletion that all the events will be lost?
2) Should i put the hostname and not the hosts_id on the events table?
3) There is a way to instruct mysql to not reuse the id number?

Ok, what is the "standard" approuch to this? :-) Like in a blog, if i remove a post, all the comments will be lost. I think that is the common behaviour... but i want to hear your opinion about that, and if there is a "good pratice".

Thanks a lot for your time!

ML

Options: ReplyQuote


Subject
Written By
Posted
How to prevent wrong references on record deletion?
M L
February 11, 2009 06:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.