CREATE TABLE customer (
cid INT (11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
cname VARCHAR (50) NOT NULL,
caddress VARCHAR (50) NOT NULL,
ccity VARCHAR (50) NOT NULL,
cstate VARCHAR (20) NOT NULL,
czip VARCHAR (20) NOT NULL,
ccountry VARCHAR (20) NULL,
ccontact VARCHAR (20) NULL,
cemail VARCHAR (20) NULL
);
CREATE TABLE product (
pid INT (11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
pname VARCHAR (50) NOT NULL,
pprice DECIMAL (8, 2) NOT NULL,
pdesc VARCHAR (100) NULL,
pcount INT (11) NOT NULL DEFAULT '0'
);
CREATE TABLE orders (
oid INT (11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
pid INT (11) NOT NULL,
cid INT (11) NOT NULL,
CONSTRAINT pid FOREIGN KEY(pid) REFERENCES product(pid),
CONSTRAINT cid FOREIGN KEY(cid) REFERENCES customer(cid),
ocount INT (11) NOT NULL DEFAULT '1',
oprice DECIMAL (8, 2) NOT NULL,
odate TIMESTAMP
);