5849l1

Listing 1. Creating a Table

CREATE TABLE AddressBook (
    person_id       SERIAL,
    first_name      TEXT   NOT NULL,
    last_name       TEXT   NOT NULL,
    address1        TEXT   NOT NULL,
    address2        TEXT   NULL    -- Not everyone needs a 2nd line
    city            TEXT   NOT NULL,
    state_province  TEXT   NULL,   -- Not everyone lives in the US
    postal_code     TEXT   NULL,   -- Not all countries have them
    phone_number    TEXT   NOT NULL,   -- Not everyone lives in the US
    fax_number      TEXT   NULL,   -- Not everyone has a fax
    cell_number     TEXT   NULL,   -- Not everyone has a cellphone

    PRIMARY KEY(person_id)
);
