NULLs in foreign keys ok?

[prev] [thread] [next] [Date index for 2005/02/14]

From: Ofer Nave
Subject: NULLs in foreign keys ok?
Date: 08:44 on 14 Feb 2005
(Sorry, just started using CDBI this weekend. BTW-Rock on, I love this 
thing.)

Assuming I have a class with a foreign key, but the foreign key can 
sometimes be null.  For example, if I had a Person class, and the person 
table had a employer_id which referred to an employer table, but some 
people might be unemployed, so they'd have employer_id set to NULL.

Is it still safe to set up a has_a relationship?  What happens if I call 
the employer() method that I set up in that case?  Does it return undef, 
indicating that this person, in fact, doesn't "have a" employer?  :)

-ofer

NULLs in foreign keys ok?
Ofer Nave 08:44 on 14 Feb 2005

Re: NULLs in foreign keys ok?
Perrin Harkins 20:45 on 14 Feb 2005

Generated at 17:31 on 15 Feb 2005 by mariachi v0.52