December 2017
Beginner
412 pages
10h 8m
English
In the real world, we often don’t have all the data we want. We might be missing the time at which an experiment was performed or the postal code of a patient being given a new kind of treatment. Rather than leave what we do know out of the database, we may choose to insert it and use the value NULL to represent the missing values. For example, if there is a region whose population we don’t know, we could insert this into our database:
| | >>> cur.execute('INSERT INTO PopByRegion VALUES ("Mars", NULL)') |
On the other hand, we probably don’t ever want a record in the database that has a NULL region name. We can prevent this from ever happening, stating that the column is NOT NULL when the table is created: ...
Read now
Unlock full access