NYCPHP Meetup

NYPHP.org

[nycphp-talk] Need help understanding NULL

Daniel Convissor danielc at analysisandsolutions.com
Sat Aug 29 16:20:48 EDT 2009


Hey Bev:

> but the concept of a ???a missing unknown value???
> makes my brain hurt.

Let's say you wrote a piece of software that asks users a set of 
questions.  Before a user responds to a given question, its answer field 
is null.  When they answer the question, its field gets assigned the 
actual value chosen by the user.  When the user finishes, sometimes they 
have skipped some questions, so they will remain null.

This is useful, in part, for statistical purposes, since the null record 
won't be added into averages, etc.  For example, you had three surveys 
filled out.  Two people actually filled in their ages (10 and 20), if you 
do an average when using nulls, you'll get an average age of 15.  But if 
you use 0's instead of nulls, the average age will incorrectly be 10.

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list