Question

In: Computer Science

I'm using livesql for my database class to try and do these A medical clinic has...

I'm using livesql for my database class to try and do these

A medical clinic has doctors, along with patients assigned to one of the doctors.

Create 2 tables that include fields below with primary key chosen below. Use appropriate data types and simplified field names, eg: -

Doctor’s Table:
DKey ID          
Last name
First name
Home phone
Medical specialty
Monthly Salary

Patient’s Table:
PKey ID          
Last name
First name
Address (Use Address as column name)
Home Phone  
Age (in years)      
DoctorID Assigned
Medical History
Add 3 doctors and about 8 patients. Values will be provided in a text file to save time.

Create 3 select statements
List all doctors,
List all patients,
Using where clause, show which doctors have which patients. (Make sure your result indicates who is Doctor and who is Patient.

List the ID num, first and last name of doctors who has a salary that is greater than 16000.

Create the following aggregate select statements.
The monthly sum of all doctors’ salaries
The average age of the patients


Write a SQL statement to show the total number of rows in Patient table. Sort by last name.


Select the lastname, firstname, assigned doctor of patients where the patient’s medical history is Diabetic.


Write a SQL statement to change one of the patient’s name “Kasuma” who recently got married and which to use her married name “Chutaw.” Patient ID number is 103. (10pts)


Write a SQL statement to increase all Doctors salary by 20% and rename column as Salary Increase


List all the patients with high blood pressure and are older than 49 years old.

text file with values are:

Doctor Table


('AM01','Abrams','Miles','617-555-6032','MD', 20000);

('BR01','Boyers','Rita','603-555-2134','MD', 15000);

('DH01','Devon','Harley','781-555-7767','MD', 17000);



Patient Table


('101','Northfold','Liam','9 Old Mill Rd. Londonderry NH','603-555-7563', '45', 'BR01', 'Breat Cancer');

('102','Ocean','Arnold','2332 South St. Apt 3 Springfield MA','413-555-3212', '55','AM01', 'Diabetic');

('103','Kasuma','Sujata','132 Main St. 1 East Hartford CT','860-555-0703','64', 'DH01', 'High Blood Pressure');

('104','Goff','Ryan','164A South Bend Rd.Lowell MA','781-555-8423','50','DH01','Left Renal abnormality');

('105','McLean','Kyle','345 Lower Ave. Wolcott NY','585-555-5321', '60','BR01', 'Diabetic');

('106','Morontoia','Joseph','156 Scholar St. Johnston RI','401-555-4848', '52','DH01','High Blood Pressure');

('107','Marchand','Quinn','76 Cross Rd. Bath NH','603-555-0456', '40','AM01','Diabetic');

('108','Rulf','Uschi','32 Sheep Stop St. Edinboro PA','814-555-5521', '75','BR01', 'Low Blood Count');

i'm stuck at creating a second table "create table patient" and livesql keeps telling me im missing a parenthesis >_<

Solutions

Expert Solution

This demonstration is using Oracle Live SQL.

1.Table Name :Doctor
create table Doctor(
ID varchar(10) primary key ,   
Lastname varchar(10),
Firstname varchar(10),
Homephone varchar(15),
Medicalspecialty varchar(5),
MonthlySalary number);

/*inserting records into Doctor table*/
insert into Doctor values ('AM01','Abrams','Miles','617-555-6032','MD', 20000);
insert into Doctor values ('BR01','Boyers','Rita','603-555-2134','MD', 15000);
insert into Doctor values ('DH01','Devon','Harley','781-555-7767','MD', 17000);

/*selecting records*/
select * from Doctor;

Screen in Oracle Live SQL :

*************************************************

2.Table Name :Patient
create table Patient(
ID varchar(10) primary key,
Lastname varchar(10),
Firstname varchar(10),
Address varchar(100),
HomePhone varchar(15) ,
Age varchar(5),
DoctorID varchar(10),
MedicalHistory varchar(100),
foreign key (DoctorID) references Doctor(ID));


/*inserting records into Patient table*/

insert into Patient values ('101','Northfold','Liam','9 Old Mill Rd. Londonderry NH','603-555-7563', '45', 'BR01', 'Breat Cancer');
insert into Patient values ('102','Ocean','Arnold','2332 South St. Apt 3 Springfield MA','413-555-3212', '55','AM01', 'Diabetic');
insert into Patient values ('103','Kasuma','Sujata','132 Main St. 1 East Hartford CT','860-555-0703','64', 'DH01', 'High Blood Pressure');
insert into Patient values ('104','Goff','Ryan','164A South Bend Rd.Lowell MA','781-555-8423','50','DH01','Left Renal abnormality');
insert into Patient values ('105','McLean','Kyle','345 Lower Ave. Wolcott NY','585-555-5321', '60','BR01', 'Diabetic');
insert into Patient values ('106','Morontoia','Joseph','156 Scholar St. Johnston RI','401-555-4848', '52','DH01','High Blood Pressure');
insert into Patient values ('107','Marchand','Quinn','76 Cross Rd. Bath NH','603-555-0456', '40','AM01','Diabetic');
insert into Patient values ('108','Rulf','Uschi','32 Sheep Stop St. Edinboro PA','814-555-5521', '75','BR01', 'Low Blood Count');

/*selecting records*/
select * from Patient;

Screen in Oracle Live SQL :

**************************************************

show which doctors have which patients :

select Doctor.ID as DoctorID,Doctor.FirstName || ' ' || Doctor.LastName as DoctorName,
Patient.Id as PatientID,Patient.FirstName || ' ' || Patient.LastName as PatientName
from doctor, patient where doctor.ID=Patient.DoctorID;

Query result :

********************************************

List the ID num, first and last name of doctors who has a salary that is greater than 16000 :

select ID,firstName,lastName from doctor where MonthlySalary>16000;

Query result :

******************************************

The monthly sum of all doctors’ salaries :

select sum(MonthlySalary) as monthlySumOfSalary from doctor;

Query result :


*******************************************

The average age of the patients :

select avg(age) as AverageAge from patient;

Query result :

********************************************

a SQL statement to show the total number of rows in Patient table. Sort by last name.:

select count(ID) as RowCount from patient order by lastName;

Query result :

**********************************************

Select the lastname, firstname, assigned doctor of patients where the patient’s medical history is Diabetic :

select patient.lastname ||' '||patient.firstName as PatientName,
Doctor.FirstName || ' ' || Doctor.LastName as DoctorName
from doctor, patient where doctor.ID=Patient.DoctorID
and medicalHistory like 'Diabetic';

Query result :

******************************************
a SQL statement to change one of the patient’s name “Kasuma” who recently got married and which to use her married name “Chutaw.” Patient ID number is 103 :

update patient set lastname='Chutaw' where ID='103';

Query result :

******************************************

a SQL statement to increase all Doctors salary by 20% and rename column as Salary Increase :

select monthlySalary,monthlySalary+monthlySalary*0.20 as SalaryIncrease from doctor;

Query result :

***************************************

List all the patients with high blood pressure and are older than 49 years old :

select * from patient where MEDICALHISTORY like 'High Blood Pressure' and
age>49;

Query result :


Related Solutions

how do medical assistant working in a private practice or clinic and the clinic has decided...
how do medical assistant working in a private practice or clinic and the clinic has decided to consider moving to an electronic system.you are highly in favor of moving to an EHR system. provide a retionale with supporting documents for a recommendation to an EHR. outline a plan for how you would transition the practice from manual to electronic records. include in your plan how EHR will provide a foundation for more accurate and secure medical records of the clinic...
I'm getting an error with my code on my EvenDemo class. I am supposed to have...
I'm getting an error with my code on my EvenDemo class. I am supposed to have two classes, Event and Event Demo. Below is my code.  What is a better way for me to write this? //******************************************************** // Event Class code //******************************************************** package java1; import java.util.Scanner; public class Event {    public final static double lowerPricePerGuest = 32.00;    public final static double higherPricePerGuest = 35.00;    public final static int cutOffValue = 50;    public boolean largeEvent;    private String...
This is for my Administrative Medical Office Skills Class Describe 4 useful rules for using proper...
This is for my Administrative Medical Office Skills Class Describe 4 useful rules for using proper telephone etiquette. State at least 5 common telephone courtesies.
Hi guys, I'm working on an assignment for my Java II class and the narrative for...
Hi guys, I'm working on an assignment for my Java II class and the narrative for this week's program has me a bit lost. I've put the narrative of the assignment in the quotation marks below. " Included with this assignment is an encrypted text file. A simple Caesar cipher was used to encrypt the data. You are to create a program which will look at the frequency analysis of the letters (upper and lowercase) to help “crack” the code...
Sometimes when I'm working with a class (usually one that represents a database model), I'll have...
Sometimes when I'm working with a class (usually one that represents a database model), I'll have about 15 different properties on it, usually of different types. These are properties that need to be accessed by the users, as well, so each property will typically need some function like T getPropertyName(); setPropertyName(T value); But, it's also extremely valuable for me to be able to iterate through each property in a particular order(although, I suppose that "value" may stem from laziness of...
My medical insurance has $1,500 deductible and then covers 90% of my medical expenses above the...
My medical insurance has $1,500 deductible and then covers 90% of my medical expenses above the deductible amount up to a maximum of $100,000. Draw the payoff diagram for my insurance policy.
Hi, I'm doing an assignment for my med-surg class. Here are the questions listed below. Describe...
Hi, I'm doing an assignment for my med-surg class. Here are the questions listed below. Describe in your own words what medical surgical nursing is. List 4 typical medical diagnosis you could see on a medical surgical unit. Give brief description of each diagnosis. List 3 nursing interventions for each diagnosis. One nursing outcome for each diagnosis you would want to see.
I'm having trouble with my ZeroDenominatorException. How do I implement it to where if the denominator...
I'm having trouble with my ZeroDenominatorException. How do I implement it to where if the denominator is 0 it throws the ZeroDenominatorException and the catch catches to guarantee that the denominator is never 0. /** * The main class is the driver for my Rational project. */ public class Main { /** * Main method is the entry point to my code. * @param args The command line arguments. */ public static void main(String[] args) { int numerator, denominator =...
im trying to complete a 2019 corporate tax return form 1120 for my class, ill try...
im trying to complete a 2019 corporate tax return form 1120 for my class, ill try to post this in as many questions as i can. 2019 2018 Property and Equipment: Equipment $          1,301,267                 931,764 Less: Accumulated depreciation                  397,056                  904,211                 293,233                         638,531 the company's depreciation expense for tax purposes is $115,000. book depreciation expense was not given, if i were to use the difference of accumulated depreciation then the book depreciation would be $103,823 should...
INTERPRETING THE REAL LIFE STORY: Diego’s Experience My fitness and wellness class motivated me to try...
INTERPRETING THE REAL LIFE STORY: Diego’s Experience My fitness and wellness class motivated me to try to quit smoking, again! It wasn’t anything new, because I had tried several times before. I had my first cigarette when I was sixteen and I have now smoked for 10 years. I have tried to quit for the last five years. But during this time, the longest I ever went without a cigarette was about three months. When we did the chapter on...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT