CREATE DATABASE rbs;
USE rbs;
CREATE TABLE ESTABS(
phone decimal(10,0) NOT NULL,
establishment char(30) NOT NULL,
city char(20),
PRIMARY KEY (phone));
CREATE TABLE EXCHANGES(
phone decimal(10,0) NOT NULL,
usual_city char(18) NOT NULL,
PRIMARY KEY (phone));
CREATE TABLE PEOPLE(
acct integer NOT NULL DEFAULT AUTOINCREMENT,
surname char(30) NOT NULL,
given_name char(30) NOT NULL,
second_init char(1),
greet_name char(30),
address_1 char(30),
address_2 char(30),
city char(20),
prov char(2),
postal char(6),
home_phone decimal(10,0),
work_phone decimal(10,0),
work_extension smallint,
birth_date integer,
sex char(1),
sol char(1),
payment_status char(1),
mail_date integer,
course_date integer,
course_type char(1),
course_sequence smallint,
course_roster smallint,
questions_missed integer,
score smallint,
percent smallint,
create_date integer,
change_date integer,
changed_by char(3),
comments1 char(30),
comments2 char(30),
comments3 char(30),
PRIMARY KEY (acct));
CREATE TABLE TAGS(
acct integer NOT NULL,
user_initials char(3) NOT NULL,
PRIMARY KEY (acct,user_initials));
CREATE TABLE TARGET_DESCS(
target smallint NOT NULL DEFAULT AUTOINCREMENT,
description char(28) NOT NULL,
people_count integer NOT NULL,
PRIMARY KEY (target));
CREATE TABLE TARGETS(
acct integer NOT NULL,
target smallint NOT NULL,
PRIMARY KEY (acct,target));
CREATE TABLE USERS(
user_initials char(3) NOT NULL,
privilege smallint NOT NULL,
people_tagged integer NOT NULL,
PRIMARY KEY (user_initials));
COMMIT WORK;