home *** CD-ROM | disk | FTP | other *** search
- MAIN
- {
- The create program creates the database tables that the leads
- program uses. It also documents their structure.
- }
- CREATE DATABASE leads
-
- CREATE TABLE contact
- {
- Each row in this table summarizes a contact with a prospect.
- }
- (
- cdate DATE,
- empnum SMALLINT, {Can join with sperson.empnum}
- ndate DATE,
- nemp SMALLINT, {Can join with sperson.empnum}
- notes CHAR (50),
- ctype CHAR (1), {C = complaint
- I = request for information
- Q = inquiry
- S = sale}
- ref INTEGER, {Can join with prospect.ref}
- cnum SERIAL {Can join with sale.cnum}
- )
- CREATE INDEX i_cref ON contact(ref)
- CREATE UNIQUE INDEX i_ccnum ON contact(cnum)
-
- CREATE TABLE prospect
- {
- This table contains information on the prospect
- (both the person and the company).
- }
- (
- fname CHAR (15),
- lname CHAR (15),
- title CHAR (6), {letter title: Mr., Ms., Dr., etc.}
- company CHAR (40),
- add1 CHAR (40),
- add2 CHAR (40),
- add3 CHAR (40),
- city CHAR (40),
- state CHAR (2),
- zip CHAR (5),
- phone CHAR (12),
- source CHAR (1), {B = binder weekly
- N = newspaper
- O = other
- P = binder production news
- R = radio}
- ref SERIAL {This column is for the use of the program;
- the user never sees it.
- Can join with contact.ref}
- )
- CREATE UNIQUE INDEX i_pref ON prospect(ref)
-
- CREATE TABLE sale
- {
- Each contact that generates a sale references a row in this table
- }
- (
- cnum INTEGER, {Can join with contact.cnum}
- pcode CHAR (10), {Can join with product.pcode}
- quantity SMALLINT,
- discount SMALLINT {stored as an integer 1-99}
- )
-
- CREATE TABLE sperson
- {
- Information on each salesperson is kept in this table. The address and
- phone are that of the salesperson's business location.
- }
- (
- empnum SMALLINT, {Can join with contact.empnum or
- Can join with contact.nemp}
- position CHAR (25),
- lname CHAR (15),
- fname CHAR (15),
- add1 CHAR (40),
- add2 CHAR (40),
- add3 CHAR (40),
- city CHAR (40),
- state CHAR (2),
- zip CHAR (5),
- phone CHAR (12)
- )
- CREATE UNIQUE INDEX i_sempnum ON sperson(empnum)
-
- CREATE TABLE product
- (
- pcode CHAR (10), {Can join with sale.pcode}
- price MONEY(6),
- descrip CHAR (30)
- )
- CREATE UNIQUE INDEX i_ppcode ON product(pcode)
-
- GRANT CONNECT TO PUBLIC
- END MAIN
-