Skip navigation links

MySQL Forums :: Foreign Keys (Referential Integrity) :: How To Implement Self-Join with Referential Integrity?


Advanced Search

Re: How To Implement Self-Join with Referential Integrity?
Posted by: Iván Nieto ()
Date: December 26, 2007 08:24AM

Just allow managerID to be NULL. You said you are trying to avoid NULLs, but what is better? A '0', invalid value for manager, or a NULL 'do not have one' value?


CREATE TABLE employees (
employeeID int(10) NOT NULL auto_increment,
employeeName varchar(50) NOT NULL,
isManager tinyint(1) NOT NULL DEFAULT 0,
managerID int(10),
PRIMARY KEY (employeeID),
FOREIGN KEY (managerID) REFERENCES employees (employeeID) ON DELETE RESTRICT
) ENGINE=InnoDB;

Options: ReplyQuote


Subject Views Written By Posted
How To Implement Self-Join with Referential Integrity? 7773 Noah Goodrich 12/08/2007 12:17AM
Re: How To Implement Self-Join with Referential Integrity? 3854 Peter Brawley 12/08/2007 12:14PM
Re: How To Implement Self-Join with Referential Integrity? 3705 Noah Goodrich 12/10/2007 10:10AM
Re: How To Implement Self-Join with Referential Integrity? 5359 Iván Nieto 12/26/2007 08:24AM


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.