Professional Documents
Culture Documents
Ramirez
Ramirez
Ramirez
Project 1: Database
Design
TRINIDAD RAMIREZ
JERRIDAN BONBRIGHT
Introduction:
The goal of designing this database for the drug store chain is to keep it simple and
promote continuity. We want the database relations to mirror the actual logistics of obtaining
prescribed drugs from the company to the patient. In addition, this business contains lots of
sensitive data that we must protect in regards to updates and access to data. In order to achieve
this goal, we will need additional entities to bridge the gaps between distributing the drug to the
pharmacy, and from the pharmacy to the doctor. We will add prescription, contract, and sales
transaction entities to ensure we keep track of where the drugs are supplied from and who they
are prescribed to.
The initial requirements of this design call for patient, doctor, pharmacy, drug, and
company entities. The patients and doctors will be easily distinguishable with the use of social
security numbers. We will also keep track of the patient’s name, age, and address. For each
doctor, we will store their name, specialty, and years of experience. Each pharmacy will have its
own name, address, and phone number. Through the use of a prescription entity, we can cover
the requirement of allowing each pharmacy to sell a drug at its own price. As for the companies
supplying the pharmacies, they will be distinguishable by name. If a company is deleted, the
drugs that they provide will be deleted as well. Doctors will prescribe and distribute the drug to
the patient. Patients should be able to obtain drugs from various doctors. A contract entity will
keep track of the contractual details regarding start and end date, text, company name, pharmacy
name, and pharmacy supervisor.
Entity Relationship Diagram:
SQL Tables:
SQL Queries:
1. Which patients have received repeat prescriptions from the pharmacy, “Pharma Med”?
Explanation:
This information may be helpful as it shows customers who have received refills or
frequently visit the pharmacy.
2. For patients who have been prescribed Albuterol, what is the name of the doctor and their
area of specialty?
Explanation:
Knowing the name of the doctor and their specialty can be useful as it tells us if doctors
are writing appropriate prescriptions for the patients they are dealing with.’
3. Which contract will expire the soonest? Display the name of the pharmacy and company
as well as the name of the contract supervisor.
Explanation:
Knowing which contract is expiring soonest can give the company or pharmacy time to
plan for a new contract and know who they need to connect with in order to discuss a
new contract.
4. Display the drug trade_name that is prescribed from doctors the most (by quantity)
Explanation:
This will help the drug store chain keep track of the drug that is being prescribed the
most. In turn, this will allow the company to prepare to order more of that drug to ensure
it’s always in stock.
5. Display the trade names, pharmacy IDs, and prices of the drugs that are above average in
price. Order by prices.
Explanation:
This can help the drug store chain keep track of items that are more expensive than the
average price. This query can be used to provide more clarity when making price
changes. The drug store chain can determine which of the expensive products they can
afford to lower the price on.
Conclusions:
Composing an ER diagram was incredibly helpful in that it provided more clarity and direction
on how we wanted to structure the tables. With the diagram created, it made the coding process
much easier since we had a reference. When processing the design phase, it helped us better
understand our project by creating visual tables and color-coating their keys. The visual
references make it clear which tables and keys we either have to union or join to produce the
desired query results.
Regarding the development process, this project exemplified the importance of design. Diagrams
and cardinalities provided a better logistical understanding of organizing data. It offered a real-
world situation and helped us think like consultants to meet customer demand.