[Helma-user] allowing NULL VALUES in foreign keys
Julian Tree
julian.tree at gmail.com
Sun Aug 20 20:34:52 CEST 2006
I came from a heavily database oriented background working a lot with
stored procedures, triggers, and foreign key constrains . I was told
to NOT allow NULL values in any database columns, because it prevents
the column from beingporperly indexed. I usually put a sentinel
value for all columns, ['' for string, 0 for number], even for
timestamps I use a sentinel value such as '0001-01-01 00:00:00' as a
place holder.
I notice helma sets a foreign_key or any key to null if one of the
parent is not set. For example files has two paretns, Job and Company
Files/type.properties------------
_table = files
_id = files_id
file_name = file_Name
job = object(Job)
job.local = file_job_id
job.foreign = job_id
company = object(Company)
company.local = file_company_id
company.foreign = company_id
-----------------------
//first add File to a job first and a few days later, assign the
file to a company
var f = new Files();
job.add(f);
// f._id = 123
/// this will insert NULL into file_company_id
How are everyone's handling NULL values on a foreign key? Is NOT NULL
column really unindexable? or am I worrying over nothing. I am using
postgresql 8.1.x, BTW.
Julian
More information about the Helma-user
mailing list