4343l2.text

Listing 2. Shopping Cart Data Structures

Cart.sql:

#
# create a sequence which we'll use to generate
# customer id's. I'm separating each id by
# an arbitrary number so that there is some space
# between each new customer to reduce the odds
# that you could guess someone else's cart number
#
create sequence seq_customer_id increment 26 start 1;

create table customers (
customer_id int not null default 0 primary key,
name text,
address text,
credit_card text,
total_order MONEY DEFAULT '$0.00'
);

create table cart_items (
cart_item serial,
customer_id int,
part_number int,
quantity int
);

create index idx_cart_customer on cart_items(customer_id);

create table item_inventory (
part_number serial,
name text,
price float,
inventory int
);

