Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a new database and execute the code below in SQL Server's query window to create the database tables. CREATE TABLE Physician Specialties. (Spesialtyin integer,

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Create a new database and execute the code below in SQL Server's query window to create the database tables. CREATE TABLE Physician Specialties. (Spesialtyin integer, SpecialtyNane varchar(5e), CONSTRAINT PK PhysicianSpecialties PRIMARY KEY (SpecialtyID)) go CREATE TABLE Zincades. (ZipCode varchar(10), City varchar(50), State varchar(2), CONSTRAINT PK.ZipCodes PRIMARY KEY (Zincode)) go CREATE TABLE Physicianrractices (PracticeIn integer, PractiseName varchar(50), Address Linel varchar(50), Address_Line2 varchar(5e), Zipcode varchar 10), Phone varchar (14) Fax varchar 14 Websiteurs varchar(5e) CONSTRAINT PK Physicianfrastices PRIMARY KEY Practicero), CONSTRAINT EK PhysicianPractices.zipcodes FOREIGN KEY (Zipcode REFERENCES Zincades.) go CREATE TABLE Physicians (Physiciant integer, First Nane varchar(40), Last Name varchar(5e), PracticeID integer Specialty integer, Email varchar(5e), CONSTRAINT PK Physicians PRIMARY KEY (PhysicianIR), CONSTRAINT EK Physicians Practices. FOREIGN KEY (PracticeID) REFERENCES PhysicianPractices. CONSTRAINT EK Physicians. PhysicianSpecialities. FOREIGN KEY (Special VID) REFERENCES Physician Specialties go CREATE TABLE Patients (Patient ID integer FirstName varchar(50) Middle Initial vacchar(1) LastName varchar se Address Linen varchar(50) Address Line2 varchar(50) Zipcode vaccharo Phonel Home varchar (14) Phone. Alternate varchar 14) Email Marchar 50 CONSTRAINT PK Patients PRIMARY KEY (Patient ID)) go CREATE TABLE Referrals (ReferralID integer, StartDate smalldatetime, EndDate smalldatetime. Patient ID integer, PhysicianID integer, CONSTRAINT PK Referrals. PRIMARY KEY (ReferralID). CONSTRAINT EK Referrals Patients. FOREIGN KEY (Patient ID) REFERENCES Patients, CONSTRAINT EK Referrals Physicians FOREIGN KEY (PhysicianID) REFERENCES Physicians) go CREATE TABLE Services Service ID integer ServiceName varchar. 50), CONSTRAINT PK ServiceID PRIMARY KEY ServiceID)) CREATE TABLE Frequencies (Frequency ID integer, Frequency varchar(30), CONSTRAINT PK Frequencies. PRIMARY KEY (FrequencyID)) go CREATE TABLE ReferralServices (ReferralID integer, ServiceID integer, Frequency ID integer, CONSTRAINT PK ReferralServices. PRIMARY KEY (ReferralID, ServiceID), CONSTRAINT EK ReferralServices Referrals FOREIGN KEY (ReferralID) REFERENCES Referrals, CONSTRAINT EK ReferralServices Services FOREIGN KEY (ServiceID) REFERENCES Services, CONSTRAINT EK ReferralServices Frequencies FOREIGN KEY (FrequencyID REFERENCES Frequencies) go CREATE TABLE Payment Types (PaymentTypeID integer Payment Type varchar 25 CONSTRAINT PKI Payment Types PRIMARY KEY Payment TypeID go CREATE TABLE Insurance Companies. (Lasurance ID integer, Insurance Company, varchar(50), Address Line1 varchar(50), Address Line2 varchar(50), ZipCode varchar(10), Phone varchar(15), Fax varchar(15), Email varchar(50), CONSTRAINT PK Insurance Companies. PRIMARY KEY (InsuranceIR), CONSTRAINT EK Insurance Companies. ZipCodes. FOREIGN KEY (ZipCode) REFERENCES ZipCodes) BO CREATE TABLE Contracts (ContractID integer, Reflennat integer StartDate smalldatetime. EndDate smalldatetime, Payment TypeID integer InsuranceID integer, NegotiatedRate float, CONSTRAINT PK .Contracts PRIMARY KEY (ContractID), CONSTRAINT PK Contracts Referrals FOREIGN KEY (ReferralID REFERENCES Referrals, CONSTRAINT FK Contracts Payment Types. FOREIGN KEY (Payment TypeID REFERENCES Payment Types, CONSTRAINT EK Contracts. Insurance Companies. FOREIGN KEY (Insurance ID) REFERENCES Insurance Companies.) go CREATE TABLE Employee Types (EmployeeTypeID integer identity, Employee Type varchar(25), CONSTRAINT PK Employee Types. PRIMARY KEY (Employee TypeID CREATE TABLE Employee Titles, (EmployeeTitle ID Integer, Employee Title varchar(30 CONSTRAINT PK EmployeeTitles PRIMARY KEY (EmployeeTitleID) go CREATE TABLE EmployeeSkilllevels Skill levelID integer SkillLevel vanchan 15 CONSTRAINT PKI Employeeskililevels PRIMARY KEY Skilllevel ID go Focus CREATE TABLE Billing Rates. (Employee TypeID integer, Skilllevel ID integer BillingRate float, CONSTRAINT PK PrimaryKey PRIMARY KEY (EmployeeTypeID, Skillleve ID), CONSTRAINT FK BillingRates EmployeeTypes. FOREIGN KEY (EmploveeTypeID REFERENCES EmploveeTypes. CONSTRAINT FK BillingRates EmployeeSkilllevels FOREIGN KEY (SkilllevelID REFERENCES EmployeeSkilllevels) go CREATE TABLE EmployeeRanks. (RankID integer, EmployeeTypeID integer, TitleID integer, Skilllevel ID integer, HourlyRate float, Salary float, CONSTRAINT PK Employee Ranks PRIMARY KEY (RankID CONSTRAINT EK EmployeeRanks Employee Types. FOREIGN KEY (EmployeeTypeID REFERENCES Employee Types CONSTRAINT EK EmployeeRanks. EmployeeTitles. FOREIGN KEY (TitleID REFERENCES EmployeeTitles CONSTRAINT EK EmployeeRanks. Employeeskililevels. FOREIGN KEY Skilllevel ID REFERENCES Employeeskilllevels 80 CREATE TABLE Employees (Employee ID integer FirstName varchar 30 Middle Initial varchant Last Name varchar se Address Line1 varchar(5e D) Focus 2 MET Talv Last Name, varchar(50), Address Line1 varchar(50), Address Line2 varchar(50), Zipcode varchar(10), Phone varchar(14), Cell Phone varchar(14), Email varchar(50), Rankir integer, Hourlybage float, Salary float CONSTRAINT PK Employees PRIMARY KEY EmployeeID CONSTRAINT EKLEDovees. EmployeeRanks. FOREIGN KEY RankID REFERENCES EmployeeRanks CONSTRAINT EKLEmployee.zipcodes. FOREIGN KEY Zincode REFERENCES ZipCodes) go CREATE TABLE Shifts (ShiftID integer, ShiftName varchar(20), Start Time time, EndTime time, CONSTRAINT PK Shifts PRIMARY KEY (ShiftID)) go CREATE TABLE DaysOfWeek (DayOfWeek ID integer, Davidleck varchar(15), CONSTRAINT PK DaysOfWeek PRIMARY KEY (DayOfWeekID)) go CREATE TABLE Availability (Employee ID integer Week of small datetime, DayOfWeek ID integer ShiftID integer CONSTRAINT PK Availability PRIMARY KEY (Employee ID. Weekof. DayOfWeekID. ShiftID) CONSTRAINT GK Availability Employees FOREIGN KEY EmployeeID REFERENCES Employees, CONSTRAINT EK Availability DaysOfWeek FOREIGN KEY DayOfWeekID REFERENCES DaysOfWeek, CONSTRAINT AK. Availability Shifts FOREIGN KEY ShiftID REFERENCES Shifts go CREATE TABLE MedicalSuppliers. (Suppliecir integer, Supplier Nuse varchar(5e), Address Linel varchar(5e), Address Line2 varchar(50), Zipcode varchar(10), Phone varchar(14), Fax varchar(14), Email varchar(52), CONSTRAINT PK MedicalSuppliers. PRIMARY KEY (Suppliecin), CONSTRAINT EK MedicalSuppliers. Zincades. FOREIGN KEY (ZipCode) REFERENCES Zipcodes) BO CREATE TABLE Supplies (SunRlYIR integer, SupriyDesscirtien varchar(40), Chana eroit float, CONSTRAINT PK Supplies PRIMARY KEY (SupplyID)) go CREATE TABLE SupplyInventory (SURR VID integer Sur Icin Integer RateReceived small datetis VoitCest float: Quantity float CONSTRAINT PK. SurplyInventory. PRIMARY KEY SURRIXID SuppliecID. DateReceived), CONSTRAINT ESARRIVInventory Supplies FOREIGN KEY Sweely I REFERENCES Supplies CONSTRAINT EK SURRIX Lowotec Suppliers FOREIGN KEY SURRLISCID REFERENCES MedicalSupplisca BO CREATE TABLE Visits (Visit In integer, RateRendered saalldatetiste, Startline time, EndTips, tine, Employee In integer, Patientia integer, CONSTRAINT PK. Visits PRIMARY KEY (Visitin), CONSTRAINT EK Visits. Employees. FOREIGN KEY (EmployeeIR) REFERENCES Employees, CONSTRAINT EK Visits Patients. FOREIGN KEY (Patientin) REFERENCES Patients) go CREATE TABLE VisitDetails (VisitID integer, VisitRetailir integer, SuprlyIR integer, SupplyQuantity integer, Service in integer Charge float, CONSTRAINT PK VisitRetails PRIMARY KEY Visitid. VisitDetailin). CONSTRAINT EK_VisitDetaiils Supplies FOREIGN KEY (SupplyID REFERENCES Supplies, CONSTRAINT EK VisitDetails Services. FOREIGN KEY SecviceID REFERENCES Services) go Write and execute queries to perform the following functions: Criteria Output Format Your Answer: Type your query in this column. The first one has been done for you. Screenshots should be pasted below this table. (Make sure the number of rows that are returned appears in the screenshot.) FirstName as 1. Display a list Patient Last Name, followed of all patients by a comma and a space, who have a last followed by the patient's first name. (e.g. Smith, John) beginning with Sort order: Patient Last the letter " Name - ascending select Lastname + PatientName from Patients where lastname like % order by lastname name Foru WC 11. Display a list of all referrals whose start date was in 2013 12. Display a list of all the referrals whose start date is between October 1, 2014 and November 5, 2014 Patient first name, followed by a space, followed by patient last name (Call this whole field "Patient Name'), Referring Physician Last Name (call this field "Physician"). StartDate, EndDate Sort Order: StartDate-ascending Patient First Name - ascending Physician Last Name ascending Patient first name, followed by a space, followed by patient last name (Call this whole field "Patient Name"), Referring Physician Last Name (call this field "Physician"), StartDate, EndDate Sort Order: StartDate ascending Patient First Name - ascending Physician Last Name ascending Physician Last name, Physician First Namne, number of referrals Sort Order: Physician Last Name ascending Physician First Name ascending 13. Display the number of referrals given by each physician Service name, number of referrals Sort order Service name 14. List the number of referrals in 2014 for each service requested 15. Display a Patient Last Name. Patient D Focus

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

SE 0 4

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago