Sie sind auf Seite 1von 5

create database CityPhysio use CityPhysio CREATE TABLE GPMASTER( GPID varchar(20) NOT NULL, GPName varchar(20) NOT

NULL, GPAddress varchar(20) NOT NULL, Constraint PK_GPID Primary Key (GPID) ) Create Table Patient ( PNo Varchar (50)NOT NULL, PName Varchar(100) NOT NULL, PAddress Varchar(100), Patient_Tel Varchar(30), PNINO Varchar (30), PGender Varchar(20), PDOB Date, PGP_ID Varchar(100), PReligion Varchar (100), Constraint PK_Patient_No Primary Key (Patient_No), CONSTRAINT FK_PGP_ID FOREIGN KEY(PGP_ID) References GPMASTER(GPID)); )

CREATE TABLE patient_next_kin ( Next_KinID varchar(30) NOT NULL, Next_Name varchar(50) NOT NULL, Next_Address varchar(100) Not NULL, Next_TelNO varchar(100) Not NULL, PNo Varchar (50) NOT NULL, CONSTRAINT PK_ Next_KinID PRIMARY KEY (Next_KinID), CONSTRAINT FK_PNo FOREIGN KEY(PNo) References Patient(PNo) ) CREATE TABLE JobType( JobTypeid varchar(20) not null, Job_description varchar(50) not null, CONSTRAINT PK_ JobTypeid PRIMARY KEY (JobTypeid) ) Create Table Expertise ( ExpertiseID Varchar (50) Not Null, ExpertiseArea VArchar (50)NOT null, Constraint PK_ExpertiseID Primary Key (ExpertiseID) ) Create Table Staff ( SId VArchar (50) Not Null, SName Varchar(75) not null, SAddress Varchar(75) Not Null, STelNo Varchar(75), STypeID VArchar (20) Not null, SExpertID VArchar (20) Not Null, Constraint PK_SId Primary Key (SId),

Constraint FK_STypeID Foreign Key (STypeID) REFERENCES JobType (JobTypeid), Constraint FK_SExpertID Foreign Key (SExpertID) REFERENCES Expertise (ExpertiseID) ) Create Table Type_Treatment ( TID Varchar(20) Not Null, TypeTreatment Varchar (50) Not Null, Constraint PK_TID Primary Key (TID) ) Create Table Treatment ( TNo Varchar(50) Not Null, PatientNo Varchar(50) Not null, StaffID Varchar(50) Not null, DateAssessment Date, Assessment_Initial Varchar(500), Diagnosis_Detail Varchar(500), Home_Excerise Varchar (50), Treatment_Agreed Varchar(100) Not Null, TID Varchar(50) Not Null, Constraint PK_TNo Primary Key (TNo), Constraint FK_PatientNo Foreign Key (PatientNo) REFERENCES Patient (PNo), Constraint FK_StaffID Foreign Key (StaffID) REFERENCES Staff (SId), Constraint FK_TID Foreign Key (TID) References Type_Treatment (TID) ) Create Table Appointment ( ANo Varchar (50) Not Null, Pat_No Varchar (50) NOt Null, Sta_ID Varchar (50) Not Null, TNo Varchar (50) Not null, Patient_Attended Varchar (50) not null, A_Date Date, Constraint PK_ANo Primary Key (Appointment_No), Constraint FK_Pat_No Foreign Key (Pat_No) REFERENCES Patient (PNo), Constraint FK_Sta_ID Foreign Key (Sta_ID) REFERENCES Staff (SId), Constraint FK_TNo Foreign Key (TNo) REFERENCES Treatment (TNo), ) select * from GPMASTER Insert INTO GPMASTER Values ('GP1', 'Dr Susane Henry', 'Barnet'), ('GP2', 'Dr Carl Lewis', 'Camden'), ('GP3', 'Dr Andrea Carter', 'Soho'), ('GP4', 'Dr Gregory Vince', 'Ealing'), ('GP5', 'Dr Rosanna Barr', 'Stratford'); select * from patient Insert INTO Patient Values

('PN001', 'Jeff Lebowski', '33 Station Road', '07962278538', 'BH 5262 565', 'Male', '1987-11-16', 'GP4', 'Atheist'), ('PN002', 'Tammy Bayman', '21 East End Road', '07934798877', 'BH 5431 765', 'Female', '1965-06-15', 'GP1', 'Jewish'), ('PN003', 'Aman Sharma', '12 Hayes Road', '07834876090', 'BHJ 5433 786', 'Male', '1976-10-11','GP3','Hindu'), ('PN004', 'Symon Shahi','18 Greenford road', '07855675678', 'BHG 9876 567', 'Female', '1985-09-27','GP5','Hindu'), ('PN005', 'Falguni Bhatt','22 Model road', '07858655678', 'BHG 8765 567', 'Female', '1985-04-13','GP2','Muslim'), ('PN006', 'Karan Sanghvi','12 The East HAM', '07879868678', 'BHG 9785 545', 'Male', '1986-10-22','GP5','Sikh'); select * from patient_next_kin Insert into patient_next_kin Values ('NK1', 'Walter Pratick', 'London','07978788322', 'PN001'), ('NK2', 'John Bayman', 'Middlesex','07867657572', 'PN002'), ('NK3', 'Manainder Singh', 'Hayes','07868276865', 'PN003'), ('NK4', 'Rachita Karki', 'Southall','07855675678', 'PN004'), ('NK5', 'Ziyad Khan', 'East HAm','07944678102', 'PN005'), ('NK6', 'Nithin Girish', 'Barking','07824567899', 'PN006'); select * from JobType Insert into JobType Values ('JT1', 'Practise Manager'), ('JT2', 'Clerical Officer'), ('JT3', 'Physiotherpaist'), ('JT4', 'Senior Physiotherpaist'); select * from Expertise Insert into Expertise Values ('Expert1', 'Sports Injuries'), ('Expert2', 'Occupational Related Injuries'), ('Expert3', 'Post Operative Rehabilation'), ('Expert4', 'orthopaedics'), ('Expert5', 'Neck and Back Problems'), ('Expert6', 'orthopaedics and Post Operative Rehabilation'), ('Expert7', 'NA');

select * from Staff Insert Into Staff Values( 'ST1', 'Sue Brown', 'London', '07987565642', 'JT3','Expert1'), ('ST2', 'Mike Hickin', 'Harrow', '07877576665', 'JT3','Expert2'), ('ST3', 'Sally Rains', 'Watford', '07467675293', 'JT3', 'Expert6'), ('ST4', 'Richard Bates', 'Barnet', '0765976459', 'JT3', 'Expert5'), ('ST5', 'John Smith', 'Wimbeldon', '07944671035', 'JT4', 'Expert4'), ('ST6', 'Rebecca Taylor', 'Camden', '07824710543', 'JT4', 'Expert4'), ('ST7', 'Hardik Dedhia', 'Croyden', '07876549765', 'JT1', 'Expert7'), ('ST8', 'Vinay Venkaetshan', 'Dagenham', '07912689765', 'JT2', 'Expert7'); select * from Type_Treatment Insert Type_Treatment Values

('T1', 'Mobilisation'), ('T2', 'MAssage Therapy'), ('T3', 'Exercise Therapy') ;

select * from Treatment Insert Treatment Values ( 'TD1','PN001','ST6','2011-04-15','Back Pain', 'Injury to the lower back three weeks rehabilaton', 'No','Yes', 'T1'), ('TD2', 'PN002','ST5','2011-05-25','Achilles Hell Injury', 'Injured Achilles will require long rehabilation, programme', 'Yes','Yes', 'T3'), ('TD3', 'PN002','ST5','2011-05-25','Achilles Hell Injury', 'Injured Achilles will require long rehabilation, programme', 'Yes','Yes', 'T2'), ('TD4', 'PN003','ST5','2011-02-21','Groin Strain', 'Groin Strain will require indepth excerise therapy', 'Yes','Yes', 'T3'), ('TD5', 'PN004','ST5','2011-01-15','Metarasal Break', 'Break in the Metatarsal made famous by david beckham', 'No','Yes', 'T2'), ('TD6', 'PN004','ST5','2011-01-15','Metarasal Break', 'Break in the Metatarsal made famous by david beckham', 'No','Yes', 'T1'), ('TD7', 'PN005','ST6','2011-04-11','Right Harm Fracture', 'thin hair line fracture in the right right elbow', 'No','Yes', 'T1'), ('TD8', 'PN006','ST6','2011-03-29','Knee injury', 'the right tendon on the knee is shattered', 'Yes','Yes', 'T1'), ('TD9', 'PN006','ST6','2011-03-29','Knee injury', 'the right tendon on the knee is shattered', 'Yes','Yes', 'T3'); select * from Appointment Insert Appointment Values ( 'AP1', 'PN001','ST2', 'TD1', 'Yes','2011-05-12'), ('AP2', 'PN002','ST4', 'TD2', 'Yes','2011-06-12'), ('AP3', 'PN002','ST1', 'TD3', 'Yes','2011-06-18'), ('AP4', 'PN003','ST4', 'TD4', 'Yes','2011-02-22'), ('AP5', 'PN004','ST1', 'TD5', 'Yes','2011-01-25'), ('AP6', 'PN004','ST5', 'TD6', 'Yes','2011-04-12'), ('AP7', 'PN005','ST1', 'TD7', 'Yes','2011-04-25'), ('AP8', 'PN006','ST6', 'TD8', 'No','2011-04-11'), ('AP9', 'PN006','ST5', 'TD9', 'Yes','2011-04-15');

select a.SId, a.SName From Staff as A, Expertise as B where A.SExpertID = B.ExpertiseID AND B.ExpertiseID =

'Expert4'

select A.PNo, A.PName, D.SName From Patient as A, Treatment as B, Type_Treatment as C, Staff as D, Appointment as E where C.TID = B.TID ANd A.PNo = B.PatientNo And B.StaffID = D.SId And C.TID = 'T1' select A.PNo, A.PName From Patient as A, Appointment as B, Type_Treatment as C, Staff as D, Treatment as E

Where A.PGender = 'Female' AND C.TID = 'T2' and D.SId = 'ST1' and D.SId = B.Sta_ID And B.TNo = E.TNo and E.TID = C.TID and B.Pat_No = A.PNo select A.PName, B.A_Date From Patient as A, Appointment as B, Staff as C Where A.PNo = B.Pat_No and C.SId = B.Sta_ID and B.A_Date BETWEEN '2011-0401' AND '2011-04-30'

Das könnte Ihnen auch gefallen