Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Project Database Design and Implementation: Part 1 & 2

Company Name: Interstellar Web Design

Project name: Drug Store Chain Database Design and Implementation

Authors: Alex O’Brien, Royal Williams, Adam Momand

Date: May 13, 2022


Project Overview

The purpose of this database is to manage all of the patient, doctor, pharmacy, and drug
information as they relate to each other. For patients, we will create a separate table to collect
their information such as: date of birth, social security number, address, and contact information.
Similarly, a separate table is created for doctors to collect their information. Pharmacy, drug
prices, and generic information of the drug will also have their own tables. We will be creating
tables for each entity as required and those tables are detailed below. Certain tables like the
Price table are entirely dependent on other tables and will be created out of necessity.

The benefits of designing a database for the purposes outlined below are that it is an easier way
to keep track of each patient and doctor’s information. With this database, it will be fairly simple
to answer complex questions by sorting and filtering important information based on the
database records.

The requirements of the database are listed below. The requirements are used to determine
which tables are created and how they are linked to other tables in the database.

1. Patients have uniquely identifying information which are social security number, date of
birth, full name, and address. This information is used to collect and record necessary
data about a patient. Medical professionals and insurance companies use this
information to help their patients and update their records.

2. Doctors have similar identifying information to patients such as: social security numbers,
expertise in specific fields, length of experience, and education. Most doctors have
biographical information on the clinic or hospital websites that they work with for public
and patient information.

3. Pharmaceutical companies have identifying information such as: address and contact
information. These companies have contracts with local pharmacies to provide them with
drugs, which their customers need and use.

4. Prescription drugs are only obtainable by prescription from a certified doctor. Prescription
drugs are manufactured and sold by pharmaceutical companies to retail pharmacies.
These drugs have a generic formula name and may also have a trade name. Trade
names must be unique, if a drug is to have one.

5. Pharmacies have name and contact information such as: website, email address, phone
number, and mailing address. These pharmacies must be registered with the local
governments, they must also be certified to practice and distribute drugs to customers
with a valid prescription.

6. Most patients have a primary physician that they go to for their primary care. These
physicians provide their patients with certified treatment in the field that they are certified
in and if they are not certified in a certain treatment, patients are referred to another
expert or certified physician that is an expert in that field.

7. Physicians can write prescriptions for any patient, this is a many to many relationship in
the SQL model. Of course, there are restrictions for physicians to only write prescriptions
in their own field and there are some government restrictions on what drug that can be
prescribed.

8. Each pharmacy sells several drugs and has a price for each. A drug could be sold at
several pharmacies and the price could vary from one pharmacy to another. Also, the
same drug can be manufactured by different pharmaceutical companies and may have
different prices at various pharmacies.

9. Doctors prescribe drugs to many patients. A prescription has a unique Rx number. This
number pertains to one drug, one patient, and is written by one doctor. A patient can
have multiple prescriptions from multiple doctors for multiple drugs.

10. Each prescription has a date and quantity associated with it. If the prescription has a
trade name, then the prescription is for a specific drug from a specific pharmaceutical
company. If the prescription is for a generic name, then any drug with that formula name
from any pharmaceutical company can be used.

11. When a prescription is filled, we want to track the pharmacy that filled it and the date that
it was filled. If it was for a generic name, we want the pharmaceutical company that
supplied the drug used to fill the prescription.

12. Pharmaceutical companies have long-term contracts with pharmacies. A pharmaceutical


company can have contracts with several pharmacies and a pharmacy can have
contracts with several pharmaceutical companies. For each contract, we want to record
the start date, end date, and the text of the contract.

13. Pharmacies appoint a supervisor for each contract. Every contract has a supervisor that
can change over time. A supervisor may be a supervisor for multiple contracts. These
pharmacies must compete with its competitors to provide better quality and prices. Also,
pharmacies must comply with government regulations.
Database Structure
The database consists of 8 tables as shown below. More detailed descriptions of each table
will follow.

Table Description

Doctor docid, Doctor SSN, name, specialty, year license started

Patient patientid, Patient SSN, name, dob, address, Doctor SSN

Prescription rx, date, quantity, drug_id, docid, patientid, pharmacyid, fill_date

Drug drug_id, trade name, generic name, PharmCompany name

PharmCompany company name, phone number

Contract number, start date, end date, text, supervisor, Pharmaceutical


company name, Pharmacy name

Pharmacy pharmacyid, pharmacy name, address, phone number

Price pharmacyid, drug_id, price

Table explanations:
Doctor
The Doctor table includes docid as the primary key and the docid will auto increment. It also
includes the doctor’s name, specialty, license start date, and SSN. The Doctor table is
connected to both the Patient and Prescription tables. In this database, it will be possible for a
doctor to have zero to many patients. In the same way, it will be possible for a doctor to have
zero to many prescriptions written. However, it is only possible for a patient to have one
doctor. Similarly, it is only possible for a prescription to have one doctor.

Patient
The Patient table includes the patientid as the primary key which will auto increment. The
table will also include the patient’s name, dob, address, and SSN. The foreign key linking the
Patient table to the Doctor table will be the docid. As stated, a patient can only have one
doctor. The Patient table is also connected to the Prescription table as the patient will have
one to many prescriptions.
Prescription
The Prescription table will use the Rx number as its primary key to identify the prescription.
The database will automatically assign an integer value to a prescription record when it is
created. The table will also consist of the quantity, date, drug_id. The drug_id is the first
foreign key of this table and comes from the Drug table. The next foreign keys this table uses
are the doctor and patient table’s primary keys. This is because a prescription is required to
have one doctor and one patient. When a prescription is filled, the pharmacyid and fill_date,
which begin with null values, will automatically populate.

Drug
This table’s job is to contain all of the drugs in the database. The drug_id will act as the
auto-incremented primary key. The table will also include the trade name and generic name.
The Drug table is connected to the PharmCompany table and uses the company’s name as
the foreign key which is not required. The table is also connected to the Price table because
pharmacies are able to have prices that differ from pharmacy to pharmacy.

PharmCompany
The PharmCompany table contains the least amount of columns of all the tables. The primary
key which serves for identification is the pharmaceutical company’s name. The table will also
include a column for a phone number. As stated above, the PharmCompany table is
connected to the PrescriptionDrug table and the pharmaceutical company is allowed to have
one to many prescription drugs. A Drug can have zero to one PharmaceuticalCompanies.
The PharmCompany table is also connected to the Contract table which serves as a way to
manage all of the contracts between pharmaceutical companies and pharmacies.

Contract
As stated above, this table will keep track of all the contracts between the pharmaceutical
companies and pharmacies. A pharmaceutical company can have one to many contracts.
This is the same case for the pharmacies. The Contract table consists of a contract number
which will serve as the primary key. It also houses the contract start date, end date (if the
contract is over), text of the contract, and the name of the supervisor assigned to the contract.
Since the Contract table relies on the pharmaceutical companies and pharmacies, the foreign
keys include the pharmaceutical company’s name and the pharmacy’s name which are the
primary keys of the two tables respectively.

Pharmacy
The Pharmacy table consists of the pharmacy’s name as the primary key. The table also
contains the address and phone number of the pharmacy. As mentioned above, the
Pharmacy table is connected to both the Contract and Price tables. A pharmacy is allowed to
have zero to many contracts just in case a pharmacy is new and does not have any contracts
yet. It is possible for the pharmacy to have one to many prices, as it is expected that the
pharmacy will be selling at least one prescription drug.
Price
The price table is entirely dependent upon the PrescriptionDrug and Pharmacy tables. In fact,
the Price table uses the primary keys of both tables as its own primary key. Those columns
include the pharmacy name from the pharmacy and the generic name of the prescription
drug. In addition to the primary key, the price table also includes the price for the drug. As
stated above, it is possible for a pharmacy to have one to many prices. Similarly, it is possible
for a prescription drug to have one to many prices, because prices may differ among
pharmacies.

NOTE: All names have a maximum character count of 35. Address components have varying
maximum character counts for street, city, state, and zip code. Phone numbers have a
maximum of 10, and social security numbers (SSN) have a maximum of 9. Therefore, dashes
should not be included in phone numbers and SSN numbers.
Create File
-- MySQL Script generated by MySQL Workbench
-- Sat May 21 08:38:03 2022
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;


SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE,
SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FO
R_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;


USE `mydb` ;

-- Table `Doctor`
CREATE TABLE IF NOT EXISTS `Doctor` (
`docid` INT NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(35) NOT NULL,
`last_name` VARCHAR(35) NOT NULL,
`specialty` VARCHAR(35) NOT NULL,
`firstyear` CHAR(4) NOT NULL,
`doctorssn` CHAR(9) NOT NULL,
PRIMARY KEY (`docid`));

-- Table `Patient`
CREATE TABLE IF NOT EXISTS `Patient` (
`patientid` INT NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(35) NOT NULL,
`last_name` VARCHAR(35) NOT NULL,
`dob` DATE NOT NULL,
`street` VARCHAR(50) NOT NULL,
`city` VARCHAR(45) NOT NULL,
`state` CHAR(2) NOT NULL,
`zipcode` VARCHAR(9) NOT NULL,
`patientssn` CHAR(9) NOT NULL,
`docid` INT NOT NULL,
PRIMARY KEY (`patientid`),
INDEX `fk_Patient_Doctor_idx` (`docid` ASC) VISIBLE,
CONSTRAINT `fk_Patient_Doctor`
FOREIGN KEY (`docid`)
REFERENCES `Doctor` (`docid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

-- Table `PharmCompany`
CREATE TABLE IF NOT EXISTS `PharmCompany` (
`companyname` VARCHAR(35) NOT NULL,
`phonenumber` CHAR(10) NOT NULL,
PRIMARY KEY (`companyname`));

-- Table `Drug`
CREATE TABLE IF NOT EXISTS `Drug` (
`drug_id` INT NOT NULL AUTO_INCREMENT,
`tradename` VARCHAR(100) NULL,
`genericname` VARCHAR(200) NULL,
`companyname` VARCHAR(35) NULL,
PRIMARY KEY (`drug_id`),
INDEX `fk_PrescriptionDrug_PharmCompany1_idx` (`companyname` ASC) VISIBLE,
CONSTRAINT `fk_PrescriptionDrug_PharmCompany1`
FOREIGN KEY (`companyname`)
REFERENCES `PharmCompany` (`companyname`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

-- Table `Pharmacy`
CREATE TABLE IF NOT EXISTS `Pharmacy` (
`pharmacyid` INT NOT NULL AUTO_INCREMENT,
`pharmacyname` VARCHAR(35) NOT NULL,
`address` VARCHAR(100) NOT NULL,
`phonenumber` CHAR(10) NULL,
PRIMARY KEY (`pharmacyid`));

-- Table `Price`
CREATE TABLE IF NOT EXISTS `Price` (
`pharmacyid` INT NOT NULL,
`drug_id` INT NOT NULL,
`price` DECIMAL(5,2) NOT NULL,
PRIMARY KEY (`pharmacyid`, `drug_id`),
INDEX `fk_PrescriptionDrug_has_Pharmacy_Pharmacy1_idx` (`pharmacyid` ASC) VISIBLE,
INDEX `fk_PrescriptionDrug_has_Pharmacy_PrescriptionDrug1_idx` (`drug_id` ASC)
VISIBLE,
CONSTRAINT `fk_PrescriptionDrug_has_Pharmacy_PrescriptionDrug1`
FOREIGN KEY (`drug_id`)
REFERENCES `Drug` (`drug_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_PrescriptionDrug_has_Pharmacy_Pharmacy1`
FOREIGN KEY (`pharmacyid`)
REFERENCES `Pharmacy` (`pharmacyid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

-- Table `Prescription`
CREATE TABLE IF NOT EXISTS `Prescription` (
`rx` INT NOT NULL AUTO_INCREMENT,
`quantity` INT NOT NULL,
`date` DATE NOT NULL,
`drug_id` INT NOT NULL,
`docid` INT NOT NULL,
`patientid` INT NOT NULL,
`pharmacyid` INT NULL,
`fill_date` DATE NULL,
PRIMARY KEY (`rx`),
INDEX `fk_Prescription_PrescriptionDrug1_idx` (`drug_id` ASC) VISIBLE,
INDEX `fk_Prescription_Doctor1_idx` (`docid` ASC) VISIBLE,
INDEX `fk_Prescription_Patient1_idx` (`patientid` ASC) VISIBLE,
INDEX `fk_Prescription_Pharmacy1_idx` (`pharmacyid` ASC) VISIBLE,
CONSTRAINT `fk_Prescription_PrescriptionDrug1`
FOREIGN KEY (`drug_id`)
REFERENCES `Drug` (`drug_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Prescription_Doctor1`
FOREIGN KEY (`docid`)
REFERENCES `Doctor` (`docid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Prescription_Patient1`
FOREIGN KEY (`patientid`)
REFERENCES `Patient` (`patientid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Prescription_Pharmacy1`
FOREIGN KEY (`pharmacyid`)
REFERENCES `Pharmacy` (`pharmacyid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

-- Table `Contract`
CREATE TABLE IF NOT EXISTS `Contract` (
`number` INT NOT NULL AUTO_INCREMENT,
`startdate` DATE NOT NULL,
`enddate` DATE NULL,
`text` VARCHAR(100) NOT NULL,
`supervisor` VARCHAR(35) NOT NULL,
`companyname` VARCHAR(35) NOT NULL,
`pharmacyid` INT NOT NULL,
PRIMARY KEY (`number`),
INDEX `fk_Contract_PharmCompany1_idx` (`companyname` ASC) VISIBLE,
INDEX `fk_Contract_Pharmacy1_idx` (`pharmacyid` ASC) VISIBLE,
CONSTRAINT `fk_Contract_PharmCompany1`
FOREIGN KEY (`companyname`)
REFERENCES `PharmCompany` (`companyname`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Contract_Pharmacy1`
FOREIGN KEY (`pharmacyid`)
REFERENCES `Pharmacy` (`pharmacyid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

Questions and SQL queries


1. Display doctor specialty, license date, patient address, and generic name from the
prescriptions they have.
select specialty, address, licensedate, genericname
from doctor join patient on doctor.doctorssn = patient.patientssn
join prescription on patient.patientssn = prescription.patientssn;

2. Display the pharmacy name, generic name, and price of all drugs from pharmacies
with the phone number beginning with ‘949’.
select ph.pharmacyname, pd.genericname, price
from prescriptiondrug pd join price p on pd.genericname = p.genericname
join pharmacy ph on ph.pharmacyname = p.pharmacyname
where phonenumber like '949%';

3. Display the doctor SSN, specialty, and prescriptions which have a quantity of more
than 10.
select d.doctorssn, specialty, rx
from doctor d join prescription p on d.doctorssn = p.doctorssn
where quantity > 10;

4. Display the ongoing contracts and the pharmaceutical company and pharmacy they
belong to.
select number, pc.companyname name, p.pharmacyname
from pharmcompany pc join contract c on pc.companyname = c.companyname
join pharmacy p on c.pharmacyname = p.pharmacyname
where enddate is null;

5. Display the maximum price of the generic name drug of any pharmacy and list the
pharmacy name.
select ph.pharmacyname, max(price)
from pharmacy ph join price p on ph.pharmacyname = p.pharmacyname
join prescriptiondrug pd on pd.genericname = p.genericname
group by pharmacyname;

FDA_Report.java JDBC Application:


This application generates a report based on the prescription’s start date, end
date, and name of the drugs.

Successful FDA Report #1:


Successful FDA Report #2:

Example of Errors:

The start date was not entered in the correct format:


The start date cannot be in the future:

End date cannot be before the start date:


Pharmacy_Manager_Report.java JDBC Application:
This application generates a report based on the prescription’s start date, end
date, name of the drugs used, and quantity of each drug used.

ControllerPatient.java Web Application


This application gives the user the option to update, display, or register the
patient’s information.
The patient does not exist in the database:

Edit Patient Information:


Patient Update Form:

Updated Database with new patient update:


Register New Patient (start to successful finish)

Part 1 (Choosing to register a new patient):

Part 2 (Entering new patient data):


Part 3 (Successfully registering a new patient):

Register New Patient (Failed Attempts)

The SSN is not entered at all:

The doctor’s name does not exist in the database:


DataGenerate.java JDBC application

This application automatically generates random information so we can properly test


our database. The application will generate 10 random doctors, 100 random patients,
100 random prescriptions, and 10 random pharmacies. Sample output is shown below
(truncated for this report):
rows from pharmacy deleted 0
rows from prescription deleted 100
rows from patient deleted 100
rows from doctor deleted 10
1 row inserted for doctor id 1
1 row inserted for doctor id 2

All doctors
1 Clark, Justin Family Medicine 2016 123458739
2 Anderson, Bob Pediatrics 2016 123451952
3 Harris, Luke Orthpedics 2003 123456025
4 Rodriguez, Tyler Dermatology 2008 123453289
5 Johnson, Jimmy Cardiology 2000 123453683
6 Johnson, Erika Gynecology 2002 123458454
7 Williams, Matthew Gastroenterology 2000 123456228
8 Johnson, Paul Psychiatry 2001 123458061
9 Momand, Mari Oncology 2014 123453275
10 Williams, Jessica Internal Medicine 2002 123458733
1 row inserted for patient id 1
1 row inserted for patient id 2

All patients
1 Rodriguez, Justin 1976-01-01 49854 Rainbow Road Green Plains
2 Lee, Zack 1965-02-11 73945 Trabuco Road Los Angeles
3 Green, Goku 1994-06-14 68849 Gingersnap Lane Rancho Santa
Margarita
4 Johnson, Skylar 1969-10-11 703 Trabuco Road Mushroom Kingdom
5 Miller, Robert 1976-11-16 62788 Highway Road Los Angeles
6 Brown, Mari 1976-01-03 72279 Sunshine Drive Los Angeles
7 Wilson, Jessica 1986-11-09 92571 Trabuco Road Palm Springs
8 Lee, Luke 1957-04-02 27343 Green Los Angeles
9 Jackson, Jessica 1978-03-31 6657 Maple Lake Forest
10 Martinez, Robert 2013-04-24 86758 Umbrella Court Los Angeles
11 Thompson, Aaron 1980-12-02 55967 Highway Road Mission Viejo
12 David, Zack 1989-10-25 66348 Trabuco Road Mission Viejo
13 Williams, Alex 1972-11-14 37999 Umbrella Court Mushroom
Kingdom
14 Johnson, Skylar 1990-06-15 5926 Rainy Way Joshua Tree
15 Harris, Kathleen 1978-12-14 5895 Rainy Way Mushroom Kingdom
16 Wilson, Sara 1980-04-12 21484 Trabuco Road Green Plains
17 Jackson, Jessica 1961-08-22 32915 Rainbow Road Downy
18 Jones, Daniel 1977-03-18 21873 Gingersnap Lane Foothill Ranch
19 Miller, Sandy 1983-08-05 60803 Umbrella Court Foothill Ranch
20 Green, Sandy 2014-08-22 51487 Sunshine Drive Mushroom
Kingdom
21 OBrien, Lauren 1996-04-08 83774 Maple Rancho Santa Margarita
22 Rodriguez, Kyle 2007-08-21 96412 Radio Drive Mission Viejo
23 Jackson, Mari 1987-07-20 78322 Umbrella Court Trabuco Canyon
24 Momand, Skylar 1956-08-22 41580 Gingersnap Lane Foothill
Ranch
25 Jackson, Aaron 1985-05-08 98952 Radio Drive Riverside
26 White, Taylor 1960-10-25 73587 Sunshine Drive Rancho Santa
Margarita
27 Moore, Jacob 1983-07-19 11224 Rainy Way Monterey
28 Brown, Mari 2009-05-05 12823 Green Monterey
29 Thompson, Mari 1961-09-18 67351 Radio Drive Mushroom
Kingdom
30 Lee, David 1977-03-03 84929 Trabuco Road Rancho Santa
Margarita
31 Taylor, Sara 2006-04-23 65192 Sunshine Drive Green Plains
32 Williams, Kyle 2005-12-04 86238 Gingersnap Lane Monterey
33 Johnson, Jimmy 1982-08-14 87830 Radio Drive Downy
34 White, Todd 1997-08-20 62598 Highway Road Green Plains
35 Thompson, Luke 1952-06-14 52604 Radio Drive Rancho Santa
Margarita
36 Anderson, Daniel 1966-10-31 60279 Rainy Way Palm Springs
37 Anderson, Tyler 1992-01-30 27709 Trabuco Road Palm Springs
38 Lee, Sara 1977-11-07 6238 Umbrella Court Foothill Ranch
39 Williams, Sara 2006-10-03 25047 Trabuco Road Joshua Tree
40 Jones, Goku 1981-04-11 83475 Radio Drive Palm Springs
41 Williams, Robert 1982-06-14 88463 Trabuco Road Green Plains
42 Jackson, Todd 1952-04-27 29216 Highway Road Mission Viejo
43 David, David 1986-12-22 20521 Highway Road Downy
44 Anderson, Sandy 2003-09-26 10878 Rainbow Road Los Angeles
45 Harris, David 1979-05-13 76823 Maple Palm Springs
46 Jones, Paul 1966-12-28 8924 Maple Trabuco Canyon
47 Jones, Goku 1994-11-06 1419 Trabuco Road Foothill Ranch
48 Harris, Kyle 2006-12-28 32124 Green Mission Viejo
49 Williams, Daniel 1992-02-28 42058 Rainy Way Mushroom Kingdom
50 Jackson, Kyle 1976-12-28 3387 Maple Los Angeles
51 White, Paul 1961-05-05 29150 Trabuco Road Joshua Tree
52 Lee, Todd 1991-05-25 41645 Trabuco Road Lake Forest
53 Johnson, Taylor 1991-07-05 12584 Rainy Way Lake Forest
54 Smith, Anthony 1984-01-16 9666 Gingersnap Lane Mission Viejo
55 Miller, Daniel 1999-01-27 97360 Gingersnap Lane Green Plains
56 Momand, Jake 1962-10-20 76489 Gingersnap Lane Palm Springs
57 Johnson, David 1979-10-10 61690 Highway Road Los Angeles
58 Green, Todd 2000-09-30 67471 Rainy Way Monterey
59 Rodriguez, Erika 1970-12-14 63350 Sunshine Drive Joshua Tree
60 Taylor, Sara 1997-09-16 27876 Trabuco Road Trabuco Canyon
61 Martinez, Lauren 1986-10-30 36756 Radio Drive Trabuco Canyon
62 Johnson, Skylar 1960-01-28 45850 Umbrella Court Mushroom
Kingdom
63 Thomas, Alex 1990-08-18 99218 Trabuco Road Downy
64 Rodriguez, Zack 1996-02-23 61546 Umbrella Court Mission Viejo
65 Momand, Madeline 2008-06-10 91891 Rainbow Road Trabuco
Canyon
66 OBrien, Mari 2003-10-09 82325 Highway Road Riverside
67 Clark, Madeline 1975-04-22 48526 Sunshine Drive Mission Viejo
68 David, Sandy 2011-05-27 2051 Umbrella Court Riverside
69 Momand, Mari 1994-02-19 73024 Trabuco Road Palm Springs
70 Jones, Goku 1981-07-22 30284 Gingersnap Lane Foothill Ranch
71 David, Luke 1989-01-10 7903 Radio Drive Rancho Santa
Margarita
72 Momand, Erika 1992-07-21 99473 Rainy Way Mission Viejo
73 Anderson, Timothy 2009-08-13 90027 Highway Road Green Plains
74 David, Daniel 2011-09-25 41381 Radio Drive Foothill Ranch
75 Green, Goku 1966-03-13 23075 Trabuco Road Trabuco Canyon
76 Jones, Anthony 1977-01-08 30765 Umbrella Court Los Angeles
77 Williams, Timothy 1995-03-24 62449 Highway Road Los Angeles
78 Jones, Matthew 1999-12-15 65120 Maple Downy
79 Momand, Bob 2009-01-05 14338 Sunshine Drive Monterey
80 Clark, David 1980-05-15 73100 Green Lake Forest
81 Brown, Kathleen 1976-02-18 87190 Umbrella Court Green Plains
82 Jones, David 1997-05-28 3447 Sunshine Drive Palm Springs
83 Clark, Tyler 2005-06-02 79600 Radio Drive Lake Forest
84 Miller, Timothy 2008-10-20 6879 Gingersnap Lane Joshua Tree
85 Rodriguez, Luke 2012-10-08 83915 Umbrella Court Downy
86 Jackson, Robert 1972-04-08 27871 Gingersnap Lane Downy
87 David, Anthony 1956-11-26 39305 Radio Drive Foothill Ranch
88 Rodriguez, Madeline 2009-04-30 14318 Sunshine Drive Joshua Tree
89 Lee, Todd 1973-05-02 48457 Rainy Way Los Angeles
90 Martinez, Shannon 1975-08-07 78053 Radio Drive Foothill Ranch
91 Thompson, David 1955-09-07 36531 Rainbow Road Green Plains
92 Brown, Bob 1951-03-31 43293 Gingersnap Lane Downy
93 White, Jacob 2007-04-25 65875 Sunshine Drive Riverside
94 Lee, Kyle 1964-10-28 8306 Maple Riverside
95 Thomas, Aaron 2004-07-04 75936 Green Palm Springs
96 Smith, Jake 2010-02-18 2823 Green Riverside
97 Brown, Goku 2012-12-09 70423 Sunshine Drive Downy
98 Clark, Jimmy 1978-02-16 3047 Rainbow Road Foothill Ranch
99 Green, Jessica 1983-03-21 11657 Gingersnap Lane Mission Viejo
100 David, Goku 1981-01-13 3556 Gingersnap Lane Joshua Tree
1 row inserted for rx 1
1 row inserted for rx 2

All prescriptions
1 18 28 10 26
2 95 8 8 42
3 3 49 2 82
4 75 15 1 69
5 43 38 9 91
6 2 24 5 1
7 51 8 7 43
8 58 3 5 71
9 82 53 5 7
10 85 13 9 87
11 22 54 8 40
12 81 13 3 9
13 28 51 2 53
14 81 54 6 93
15 19 18 8 40
16 27 39 9 57
17 57 35 1 5
18 3 30 7 43
19 48 34 7 21
20 1 26 3 73
21 45 48 3 48
22 69 14 10 26
23 24 47 1 33
24 63 53 10 4
25 35 54 6 56
26 26 45 6 38
27 70 60 5 18
28 71 50 3 9
29 61 14 5 66
30 87 44 10 4
31 80 57 3 48
32 87 54 3 49
33 76 21 1 11
34 26 16 9 51
35 78 8 4 61
36 89 2 8 32
37 26 4 1 47
38 35 1 1 11
39 96 35 7 84
40 65 11 7 84
41 83 5 5 66
42 70 16 9 36
43 28 45 3 86
44 8 25 8 40
45 42 50 3 34
46 48 2 5 90
47 81 1 4 70
48 86 32 5 1
49 92 7 10 62
50 49 50 5 28
51 74 34 7 52
52 29 15 8 35
53 10 43 8 35
54 40 40 5 7
55 24 29 10 24
56 80 3 5 72
57 12 6 8 42
58 60 45 3 34
59 37 19 9 87
60 68 48 9 74
61 77 31 3 99
62 50 30 3 20
63 83 56 10 98
64 51 17 2 53
65 76 48 1 2
66 33 58 5 28
67 42 37 10 4
68 74 40 5 90
69 47 49 1 33
70 65 5 9 51
71 3 22 10 15
72 11 12 7 84
73 49 11 5 7
74 94 14 2 64
75 23 43 3 46
76 16 50 10 17
77 75 17 5 18
78 53 9 9 6
79 13 25 3 99
80 59 26 2 64
81 51 23 7 16
82 88 1 1 47
83 58 29 3 73
84 69 8 6 60
85 54 14 1 29
86 92 32 6 38
87 46 29 3 3
88 70 21 3 3
89 15 57 5 66
90 24 45 5 77
91 97 49 5 18
92 30 23 9 67
93 77 23 3 86
94 78 49 2 39
95 74 13 2 58
96 91 25 6 63
97 75 3 5 28
98 88 9 5 90
99 6 21 3 20
100 30 55 4 70
1 row inserted for pharmacy 1
1 row inserted for pharmacy 2

All pharmacies
1 RX4U 53797 Umbrella Court, Lake Forest, RI 84720
5933071814
2 PillsRUs 38770 Trabuco Road, Mission Viejo, AR 46893
7394625378
3 RX4U 78595 Green, Palm Springs, ND 14407
3146842146
4 CVS 39079 Trabuco Road, Downy, MS 98583
3125036865
5 Drug Palace 79761 Green, Riverside, KS 28403
9048768765
6 PillsRUs 92396 Rainbow Road, Monterey, FL 53309
4341166632
7 Good Neighbor Pharmacy 96193 Green, Mushroom Kingdom, SD 78109
4916079766
8 PillsRUs 94360 Trabuco Road, Monterey, NC 59925
7048466778
9 Target 35516 Green, Foothill Ranch, TN 20176
8697262029
10 Good Neighbor Pharmacy 37414 Umbrella Court, Los Angeles, KY 35967
2548113473
PrescriptionCreate.java Web Application

The web application used to create a prescription will allow doctors to create a
prescription for patients using personally identifying information.

The screenshots below show the process of writing a new prescription as a doctor,
and some error messages that appear if the data is not input correctly:

The drug does not exist in the database drug table:


The doctor SSN and name does not match the database:

The doctor input only 8 digits for the SSN:


Successful creation of a new prescription:

PrescriptionFill.java Web Application

The web application used to fill prescriptions verifies that the rx exists in the database
and matches the patient’s last name, adds a fill date, and pharmacy name to the
record:
The screenshots below displays the process of a patient filling a prescription and
some errors that can occur:

The pharmacy and address cannot be blank:

The rx number needs to match the patient’s last name:


Successful filling of prescription:

The pharmacyid and fill date are automatically added to the database:

Normalization

In order to reduce the duplication of data in this database project, our team used the third
normal form (3NF) for our normalization process. We have confirmed that none of the
columns in our tables are dependent on anything other than the primary keys. With this
approach in our design of the database, we avoided data anomalies and ensured data
integrity, all while simplifying the management of the data in the database.

Summary

This is a group assignment and part one and two of a two week project. We worked on this
assignment as a team. So far we have learned the creation of relational tables, models,
normalization, updating tables, adding data to the tables, and modifying tables. This
assignment allowed us to implement what we have learned in CST 363 Introduction to
Database Systems. We are looking forward to what more this class has to offer.

You might also like