0% found this document useful (0 votes)
18 views12 pages

Team 7 A

Uploaded by

api-755510937
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views12 pages

Team 7 A

Uploaded by

api-755510937
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

1

Marine Mammal Consulting

Drug Store Chain Database Design

Andrew Grant
Sukhdeep Malhi (Sukh)

CST363: Intro to Database Design


May 30, 2023
2

Introduction:
We are Marine Mammal Consulting. We will make your business more profitable
by way of our expertise in data management and organization. We have over 20
years of experience in the field and have just opened up our new offices in sunny
Carmel, California. We are extremely excited to take on the task of helping your
drug stores to become a staple in the industry, the mecca of medication as we see
it.

We will break down the necessary details of every entity related to the business to
understand the process in its entirety. We will keep track of every patient’s
personal information, along with their physician’s, to start. We will consider the
drugs that will be most profitable for your stores to carry as well as the
pharmaceutical companies that provide them. We will consider the number of
pharmacies that are currently operational as well as the region in which they are
located. We will take a look at the information in the prescription as written from
physician to patient, as well as the necessary documentation when a prescription
is filled. We will carefully review the contract in place between your drug stores
and the pharmaceutical companies that supply you with medication. We will also
consider and document information about your choice of supervisor as they
negotiate and work out the details of said contracts.

For the purpose of our analysis we will assume constant costs of medication
regardless of quantity as it is purchased from the pharmaceutical company. As
this medication is sold to a patient, we will again assume a constant selling price
regardless of the quantity sold.

Among our additional considerations for your pharmacies are ensuring a sizable
profit margin as you purchase medication from pharmaceutical companies and
sell it to patients, that is selecting profitable medications, and ensuring that
medication that is in high demand will be readily available from your pharmacies.
We will consider ideal regions in which your pharmacies may be located. We will
also nominate candidates to act as supervisor to oversee negotiations with the
pharmaceutical companies given our vast network of talented, hard-bargaining
business associates.

We look forward to this journey with you and are excited to see the results. We
thank you again for choosing Marine Mammal Consulting.
3

Database Information

There are a total of twelve tables in this database that contain patient, doctor,
drug, and drug company information. Patient and Doctor tables are designed to
store main information such as their personal details.

Database Content Explanation

Patient Contains patient’s personal information such as SSN, name,


address, and birthday

Doctor Contains Doctor’s information such as SSN, name, speciality and


start date

DrugMadeBy Provides manufacturer details and drug price, made to link the
PharmaCompany table

Drug Drug table essential for providing formula name and trade name
that is linked to Drug pricing table

Prescription Uses Doctors and Patients SSN as a key from Patient and Doctor
table, stores drug quantity and issue date details

PharmaCompany Contains specific information about pharma company such as


company name and phone number

DrugPricing Linked with the Drug table and stores price details per pill

PrescriptionFilled Linked with the Patient, Doctor and prescription tables and
contains additional information about prescription SSN of patient
and doctor.

Pharmacy Contains specific pharmacy details such as pharmacy name,


address, and phone number

Contract Designed to store contract details of a specific company, contains


start and end date of the contract Pharma Company

Supervisor Contains supervisor’s information (supervisor’s name, id) as well


as the number of contracts the Supervisor has previously worked
on

Region Joined to the Pharmacy tables and stores region details such as
name of a region
4

Database Design and Considerations

The database structure consists of required entities, and attributes . For example,
the patient entity is one unique entity that consists of information specific to a
patient. The diagram uses 1:1, 1:Many, and Many:Many relationships depending on
a relation of the entity. Moreover, the model follows a normalization process and
avoids any redundancy. For example, the speciality column in the doctor table has
nothing to do with the patient table.
Each table consists of a primary key and is used as an identifier to join one entity
with another. The database allows access to information from one table to another
through identifiers.

While working on the model, we realized that it would be better to have


“birthdate” for patients instead of “age”. Birthdays are constant, but age changes
every year. We made the assumption that the prescription table did not need an id,
but it is necessary to have a drugid in the prescription table. It will act as an
attribute of the prescription. The prescription table now has “drugid” which is
also a foreign key to the “Drug” entity.

In order to consider the cost of medication we record ‘pricePerPill’ in the


‘DrugMadeBy’ table which refers to the cost per pill as it is purchased from a
pharmaceutical company. ‘pricePerPill’ is also located in the ‘DrugPricing’ table
which keeps track of the cost per pill as it is sold to a patient. This allows us to
compare costs and determine which medications may lead to higher profitability
for the pharmacies. The variable used for ‘pricePerPill’ in all cases was
Decimal(6,2) indicating a minimum value of $0.00 and maximum value of
$9999.99/per pill.

It was our goal to store and organize data that will be of use to the pharmacies. For
example in the ‘Supervisor’ table which keeps track of the supervisors who
oversee the contract negotiations between pharmacy and pharmaceutical
company, we store ‘careerContracts’ which refers to the number of previously
negotiated contracts by the supervisor. This field is not set to ‘not null,’ that is the
supervisor may not have any previous experience with these kinds of contracts,
however storing this field can be useful in the long run in determining qualified
candidates to negotiate the best possible prices for the pharmacy.
5

Questions and Queries for Better Understanding the Data

1. Display drug formula name and drugid with lowest cost per pill

select Drug.formulaName, Drug.idDrug, DrugMadeBy.pricePerPill


from Drug join DrugMadeBy on Drug.idDrug = DrugMadeBy.idDrug
order by DrugMadeBy.pricePerPill limit 1;

2. Display the margins for medications as they are purchased from the
pharmaceutical company and sold to the public in order of highest to
lowest

select DrugMadeBy.idDrug,
(DrugPricing.pricePerPill - DrugMadeBy.pricePerPill) as drugMargin
from DrugMadeBy join DrugPricing on DrugMadeBy.idDrug = DrugPricing.idDrug
order by drugMargin desc;

3. Display the average quantity of medication requested in a prescription

select avg(prescription.quantity) as 'Average Quantity'


from prescription;

4. Display a list of supervisors with at least 5 contracts negotiated


previously in their career?

select supervisorName, careerContracts


from Supervisor
where careerContracts >= 5;

5. Display the pharmaceutical company that appears most often in the


prescriptions that are filled

select count(*) as NumberOccur, idPharmaCompany


from PrescriptionFilled
group by idPharmaCompany
order by NumberOccur desc;
6

Entity Relationship Model


7

Web App Results

Creating a prescription:
We ensured that when entering information for a new prescription that the Doctor SSN and
Doctor name, Patient SSN and Patient name, matched doctors and patients in the database. We
also ensured that the drug chosen for the prescription was in our database.
For the purposes of combining Workbench with Eclipse and being able to randomly generate
new doctor’s names, we created full names for the doctor’s first name, and Dr. for the last
name, as you will see in the screenshots below as the form gradually gets filled in with correct
fields that avoid error messages.

Doctor SSN Doctor SSN is on file Doctor’s SSN and names now
is not on file but does match a name match but the patient info doesn’t

Doctor SSN and names match All doctor and patient info All doctor and patient
Patient SSN is on file checks out but the drug is info is one file and
But Patient SSN does not not on file the requested drug
match Patient name is on file
8

Filling a prescription:
We ensured that when filling a prescription that the Rx ID is recognized and matched with the
patient’s last name to ensure an accurate prescription is returned. In completing the
prescription, the remaining fields are supplied, in this case the default information of the drug
store here being Otter Drugs, located at 123 Otter Way.

Information does not An actual Rx has been supplied The Rx now matches the
match a prescription but it does not match the last name and proceeds to
on file last name entered update prescription. More
fields will be synced in the
next update.

Looking up and displaying patient information:


When a patient has already been registered in the system, their file can be looked up with their
patient ID and last name. If the information does not match it will display an error message.

Patient ID: 1234 and last name: Name Patient ID: 8150 and last name: Johnson
do not match anything on file match a record in the database and pulls up
the patient’s information
9

Registering a new patient:


The patient registration form verifies that information was supplied into each form field.
Entries for SSN and Zipcode are ensured to be numbers and their proper lengths. In addition,
the primary physician name will need to match a doctor on file and if the patient is less than 18
years old they only be able to select a doctor whose specialty is Family Medicine.

SSN is too short and SSN was left blank and Zipcode was entered with
is rejected again is rejected ‘Zipcode’ which is not a
number. The same result will
happen with SSN

SSN and Zipcode are All fields are correct, however All fields were filled in with
validated. Fields are full. since the birthdate indicates proper input. Since the
However the physician the patient is under the age of patient is too young, a
is not on file. 18. A physician who works in physician working in
Family Medicine will have to Family Medicine was chosen.
be selected.
10

JDBC Results

Reviewing the console reports:


We reviewed the last three years of sales of medications and focused on two criteria: the drugs
sold in the highest quantities and the drugs prescribed most often. We compiled lists of the top
10 of each category across several years to help get a sense of what Otter Drugs should perhaps
prioritize in its inventory.

Output of our Report.java which analyzes the data from prescriptions in the database.
The first row shows the drugs that were sold in the highest quantities across
2020, 2021, and 2022:

Next we see the drugs that were prescribed most often during the years 2020, 2021 and 2022:
11

Reviewing the output for DataGenerate.java:


DataGenerate.java randomly generates 10 doctors, 100 patients and 100 prescriptions. Here
with some simple print statements we can visualize the randomized data that was added to the
database that helped populate Report.java.

Randomly generated doctors:

Randomly generated patients:

Randomly generated prescriptions:


12

Conclusion

We thank you for the opportunity to provide the consultation that will elevate your
business to the next level. Here at Marine Mammal Consulting we are forward
thinking and solutions driven and look forward to utilizing our vast expertise of
database design and management to help you in this venture and the next.

You might also like