Choosing Other Column Properties

Besides deciding what data types and sizes you should use for your columns, you should consider a handful of other properties.

First, every type can also be set as NOT NULL. The NULL value, in databases and programming, is equivalent to saying that the field has no value. Ideally, every field of every record in a database should have a value, but that is rarely the case in reality. To force a field to have a value, you add the NOT NULL description to its column type. For example, a required dollar amount can be described as

cost DECIMAL(5,2) NOT NULL

When creating a table, you can also specify a default value for any type. In cases where a majority of the records will have the same value for a column, presetting ...

Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.