Listing 1. Defining the People Table
CREATE TABLE People (
person_id SERIAL NOT NULL,
first_name VARCHAR(20) NOT NULL CHECK
(first_name <>
''),
last_name VARCHAR(20) NOT NULL CHECK
(last_name <>''),
address1 VARCHAR(30) NULL CHECK
(address1 <>''),
address2 VARCHAR(30) NULL CHECK
(address2 <>''),
email VARCHAR(50) NOT NULL CHECK
(email ~'@'),
city VARCHAR(30) NULL CHECK
(city <>''),
state VARCHAR(2) NULL CHECK
(state <>''),
postal_code VARCHAR(10) NULL CHECK
(postal_code <>''),
country VARCHAR(20) NOT NULL CHECK
(country <>''),
comments TEXT NULL CHECK
(comments <>''),
PRIMARY KEY(person_id),
UNIQUE(email)
);
Copyright © 1994 - 2019 Linux Journal. All rights reserved.