SQL 练习/医院
外观
< SQL 练习
获取所有执行过从未获得认证的医疗操作的医生的姓名。
点击查看解决方案
SELECT Name FROM Physician WHERE EmployeeID IN ( SELECT Physician FROM Undergoes U WHERE NOT EXISTS ( SELECT * FROM Trained_In WHERE Treatment = Procedure AND Physician = U.Physician ) );
SELECT P.Name FROM Physician AS P, (SELECT Physician, Procedure FROM Undergoes EXCEPT SELECT Physician, Treatment FROM Trained_in) AS Pe WHERE P.EmployeeID=Pe.Physician]
SELECT Name FROM Physician WHERE EmployeeID IN ( SELECT Undergoes.Physician FROM Undergoes LEFT JOIN Trained_In ON Undergoes.Physician=Trained_In.Physician AND Undergoes.Procedures=Trained_In.Treatment WHERE Treatment IS NULL );
SELECT Physician.Name FROM Physician INNER JOIN Undergoes ON Physician.EmployeeID = Undergoes.Physician LEFT JOIN Trained_In ON Undergoes.Procedure = Trained_In.Treatment AND Physician.EmployeeID = Trained_In.Physician WHERE Trained_In.Treatment IS NULL GROUP BY Physician.EmployeeID
与上一个查询相同,但在结果中包含以下信息:医生姓名,操作名称,操作执行日期,操作执行对象的患者姓名。
点击查看解决方案
SELECT P.Name AS Physician, Pr.Name AS Procedure, U.Date, Pt.Name AS Patient FROM Physician P, Undergoes U, Patient Pt, Procedure Pr WHERE U.Patient = Pt.SSN AND U.Procedure = Pr.Code AND U.Physician = P.EmployeeID AND NOT EXISTS ( SELECT * FROM Trained_In T WHERE T.Treatment = U.Procedure AND T.Physician = U.Physician );
SELECT P.Name,Pr.Name,U.Date,Pt.Name FROM Physician AS P, Procedure AS Pr, Undergoes AS U, Patient AS Pt, (SELECT Physician, Procedure FROM Undergoes EXCEPT SELECT Physician, Treatment FROM Trained_in) AS Pe WHERE P.EmployeeID=Pe.Physician AND Pe.Procedure=Pr.Code AND Pe.Physician=U.Physician AND Pe.Procedure=U.Procedure AND U.Patient=Pt.SSN
获取所有执行过已获得认证的医疗操作的医生的姓名,但该操作是在医生认证过期(Trained_In.CertificationExpires)后的日期(Undergoes.Date)执行的。
点击查看解决方案
SELECT Name FROM Physician WHERE EmployeeID IN ( SELECT Physician FROM Undergoes U WHERE Date > ( SELECT CertificationExpires FROM Trained_In T WHERE T.Physician = U.Physician AND T.Treatment = U.Procedure ) );
SELECT P.Name FROM Physician AS P, Trained_In T, Undergoes AS U WHERE T.Physician=U.Physician AND T.Treatment=U.Procedure AND U.Date>T.CertificationExpires AND P.EmployeeID=U.Physician
与上一个查询相同,但在结果中包含以下信息:医生姓名,操作名称,操作执行日期,操作执行对象的患者姓名以及认证过期日期。
点击查看解决方案
SELECT P.Name AS Physician, Pr.Name AS Procedure, U.Date, Pt.Name AS Patient, T.CertificationExpires FROM Physician P, Undergoes U, Patient Pt, Procedure Pr, Trained_In T WHERE U.Patient = Pt.SSN AND U.Procedure = Pr.Code AND U.Physician = P.EmployeeID AND Pr.Code = T.Treatment AND P.EmployeeID = T.Physician AND U.Date > T.CertificationExpires;
获取患者与除其主治医生以外的医生会诊的预约信息。显示以下信息:患者姓名,医生姓名,护士姓名(如有),预约开始和结束时间,检查室以及患者主治医生的姓名。
点击查看解决方案
SELECT Pt.Name AS Patient, Ph.Name AS Physician, N.Name AS Nurse, A.Start, A.End, A.ExaminationRoom, PhPCP.Name AS PCP FROM Patient Pt, Physician Ph, Physician PhPCP, Appointment A LEFT JOIN Nurse N ON A.PrepNurse = N.EmployeeID WHERE A.Patient = Pt.SSN AND A.Physician = Ph.EmployeeID AND Pt.PCP = PhPCP.EmployeeID AND A.Physician <> Pt.PCP;
Undergoes 中的 Patient 字段是冗余的,因为我们可以从 Stay 表中获取它。没有强制约束来防止这两个表之间出现不一致。更具体地说,Undergoes 表可能包含一行,其中患者 ID 与我们通过 Undergoes.Stay 外键从 Stay 表中获取的 ID 不匹配。选择 Undergoes 中所有显示此不一致性的行。
点击查看解决方案
SELECT * FROM Undergoes U WHERE Patient <> ( SELECT Patient FROM Stay S WHERE U.Stay = S.StayID );
获取所有曾为 123 号房间值班的护士的姓名。
点击查看解决方案
SELECT N.Name FROM Nurse N WHERE EmployeeID IN ( SELECT OC.Nurse FROM On_Call OC, Room R WHERE OC.BlockFloor = R.BlockFloor AND OC.BlockCode = R.BlockCode AND R.Number = 123 );
医院有几个用于进行预约的检查室。获取每个检查室进行的预约次数。
注意:以下解决方案在 MS SQL Server Management Studio 中失败,并显示以下消息
Msg 306, Level 16, State 2, Line 473 The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
点击查看解决方案
SELECT ExaminationRoom, COUNT(AppointmentID) AS Number FROM Appointment GROUP BY ExaminationRoom;
获取所有患者的姓名(还包括每个患者的主治医生的姓名),使得以下所有条件都为真
- 患者已由其主治医生开具了一些药物。
- 患者接受过费用超过 5000 美元的治疗。
- 患者至少有两次预约,其中准备预约的护士是注册护士。
- 患者的主治医生不是任何科室的主任。
点击查看解决方案
SELECT Pt.Name, PhPCP.Name FROM Patient Pt, Physician PhPCP WHERE Pt.PCP = PhPCP.EmployeeID AND EXISTS ( SELECT * FROM Prescribes Pr WHERE Pr.Patient = Pt.SSN AND Pr.Physician = Pt.PCP ) AND EXISTS ( SELECT * FROM Undergoes U, Procedure Pr WHERE U.Procedure = Pr.Code AND U.Patient = Pt.SSN AND Pr.Cost > 5000 ) AND 2 <= ( SELECT COUNT(A.AppointmentID) FROM Appointment A, Nurse N WHERE A.PrepNurse = N.EmployeeID AND N.Registered = 1 AND A.Patient = Pt.SSN ) AND NOT Pt.PCP IN ( SELECT Head FROM Department );
请注意此处提供的语法适用于 SQLite 系统。作者已在 sqlite3
上对其进行了测试。点击下方查看 MYSQL 语法,已在 MYSQL5
上进行测试。请注意,由于某些字段在 MYSQL 中是保留字,因此一些字段的名称必须从 sqlite
版本更改。
点击查看 MySQL 语法。
DROP TABLE IF EXISTS Physician; CREATE TABLE Physician ( EmployeeID INTEGER NOT NULL, Name VARCHAR(30) NOT NULL, Position VARCHAR(30) NOT NULL, SSN INTEGER NOT NULL, CONSTRAINT pk_physician PRIMARY KEY(EmployeeID) ); DROP TABLE IF EXISTS Department; CREATE TABLE Department ( DepartmentID INTEGER NOT NULL, Name VARCHAR(30) NOT NULL, Head INTEGER NOT NULL, CONSTRAINT pk_Department PRIMARY KEY(DepartmentID), CONSTRAINT fk_Department_Physician_EmployeeID FOREIGN KEY(Head) REFERENCES Physician(EmployeeID) ); DROP TABLE IF EXISTS Affiliated_With; CREATE TABLE Affiliated_With ( Physician INTEGER NOT NULL, Department INTEGER NOT NULL, PrimaryAffiliation BIT NOT NULL, CONSTRAINT fk_Affiliated_With_Physician_EmployeeID FOREIGN KEY(Physician) REFERENCES Physician(EmployeeID), CONSTRAINT fk_Affiliated_With_Department_DepartmentID FOREIGN KEY(Department) REFERENCES Department(DepartmentID), PRIMARY KEY(Physician, Department) ); DROP TABLE IF EXISTS Procedures; CREATE TABLE Procedures ( Code INTEGER PRIMARY KEY NOT NULL, Name VARCHAR(30) NOT NULL, Cost REAL NOT NULL ); DROP TABLE IF EXISTS Trained_In; CREATE TABLE Trained_In ( Physician INTEGER NOT NULL, Treatment INTEGER NOT NULL, CertificationDate DATETIME NOT NULL, CertificationExpires DATETIME NOT NULL, CONSTRAINT fk_Trained_In_Physician_EmployeeID FOREIGN KEY(Physician) REFERENCES Physician(EmployeeID), CONSTRAINT fk_Trained_In_Procedures_Code FOREIGN KEY(Treatment) REFERENCES Procedures(Code), PRIMARY KEY(Physician, Treatment) ); DROP TABLE IF EXISTS Patient; CREATE TABLE Patient ( SSN INTEGER PRIMARY KEY NOT NULL, Name VARCHAR(30) NOT NULL, Address VARCHAR(30) NOT NULL, Phone VARCHAR(30) NOT NULL, InsuranceID INTEGER NOT NULL, PCP INTEGER NOT NULL, CONSTRAINT fk_Patient_Physician_EmployeeID FOREIGN KEY(PCP) REFERENCES Physician(EmployeeID) ); DROP TABLE IF EXISTS Nurse; CREATE TABLE Nurse ( EmployeeID INTEGER PRIMARY KEY NOT NULL, Name VARCHAR(30) NOT NULL, Position VARCHAR(30) NOT NULL, Registered BIT NOT NULL, SSN INTEGER NOT NULL ); DROP TABLE IF EXISTS Appointment; CREATE TABLE Appointment ( AppointmentID INTEGER PRIMARY KEY NOT NULL, Patient INTEGER NOT NULL, PrepNurse INTEGER, Physician INTEGER NOT NULL, Starto DATETIME NOT NULL, Endo DATETIME NOT NULL, ExaminationRoom TEXT NOT NULL, CONSTRAINT fk_Appointment_Patient_SSN FOREIGN KEY(Patient) REFERENCES Patient(SSN), CONSTRAINT fk_Appointment_Nurse_EmployeeID FOREIGN KEY(PrepNurse) REFERENCES Nurse(EmployeeID), CONSTRAINT fk_Appointment_Physician_EmployeeID FOREIGN KEY(Physician) REFERENCES Physician(EmployeeID) ); DROP TABLE IF EXISTS Medication; CREATE TABLE Medication ( Code INTEGER PRIMARY KEY NOT NULL, Name VARCHAR(30) NOT NULL, Brand VARCHAR(30) NOT NULL, Description VARCHAR(30) NOT NULL ); DROP TABLE IF EXISTS Prescribes; CREATE TABLE Prescribes ( Physician INTEGER NOT NULL, Patient INTEGER NOT NULL, Medication INTEGER NOT NULL, Date DATETIME NOT NULL, Appointment INTEGER, Dose VARCHAR(30) NOT NULL, PRIMARY KEY(Physician, Patient, Medication, Date), CONSTRAINT fk_Prescribes_Physician_EmployeeID FOREIGN KEY(Physician) REFERENCES Physician(EmployeeID), CONSTRAINT fk_Prescribes_Patient_SSN FOREIGN KEY(Patient) REFERENCES Patient(SSN), CONSTRAINT fk_Prescribes_Medication_Code FOREIGN KEY(Medication) REFERENCES Medication(Code), CONSTRAINT fk_Prescribes_Appointment_AppointmentID FOREIGN KEY(Appointment) REFERENCES Appointment(AppointmentID) ); DROP TABLE IF EXISTS Block; CREATE TABLE Block ( BlockFloor INTEGER NOT NULL, BlockCode INTEGER NOT NULL, PRIMARY KEY(BlockFloor, BlockCode) ); DROP TABLE IF EXISTS Room; CREATE TABLE Room ( RoomNumber INTEGER PRIMARY KEY NOT NULL, RoomType VARCHAR(30) NOT NULL, BlockFloor INTEGER NOT NULL, BlockCode INTEGER NOT NULL, Unavailable BIT NOT NULL, CONSTRAINT fk_Room_Block_PK FOREIGN KEY(BlockFloor, BlockCode) REFERENCES Block(BlockFloor, BlockCode) ); DROP TABLE IF EXISTS On_Call; CREATE TABLE On_Call ( Nurse INTEGER NOT NULL, BlockFloor INTEGER NOT NULL, BlockCode INTEGER NOT NULL, OnCallStart DATETIME NOT NULL, OnCallEnd DATETIME NOT NULL, PRIMARY KEY(Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd), CONSTRAINT fk_OnCall_Nurse_EmployeeID FOREIGN KEY(Nurse) REFERENCES Nurse(EmployeeID), CONSTRAINT fk_OnCall_Block_Floor FOREIGN KEY(BlockFloor, BlockCode) REFERENCES Block(BlockFloor, BlockCode) ); DROP TABLE IF EXISTS Stay; CREATE TABLE Stay ( StayID INTEGER PRIMARY KEY NOT NULL, Patient INTEGER NOT NULL, Room INTEGER NOT NULL, StayStart DATETIME NOT NULL, StayEnd DATETIME NOT NULL, CONSTRAINT fk_Stay_Patient_SSN FOREIGN KEY(Patient) REFERENCES Patient(SSN), CONSTRAINT fk_Stay_Room_Number FOREIGN KEY(Room) REFERENCES Room(RoomNumber) ); DROP TABLE IF EXISTS Undergoes; CREATE TABLE Undergoes ( Patient INTEGER NOT NULL, Procedures INTEGER NOT NULL, Stay INTEGER NOT NULL, DateUndergoes DATETIME NOT NULL, Physician INTEGER NOT NULL, AssistingNurse INTEGER, PRIMARY KEY(Patient, Procedures, Stay, DateUndergoes), CONSTRAINT fk_Undergoes_Patient_SSN FOREIGN KEY(Patient) REFERENCES Patient(SSN), CONSTRAINT fk_Undergoes_Procedures_Code FOREIGN KEY(Procedures) REFERENCES Procedures(Code), CONSTRAINT fk_Undergoes_Stay_StayID FOREIGN KEY(Stay) REFERENCES Stay(StayID), CONSTRAINT fk_Undergoes_Physician_EmployeeID FOREIGN KEY(Physician) REFERENCES Physician(EmployeeID), CONSTRAINT fk_Undergoes_Nurse_EmployeeID FOREIGN KEY(AssistingNurse) REFERENCES Nurse(EmployeeID) );
CREATE TABLE Physician ( EmployeeID INTEGER PRIMARY KEY NOT NULL, Name TEXT NOT NULL, Position TEXT NOT NULL, SSN INTEGER NOT NULL ); CREATE TABLE Department ( DepartmentID INTEGER PRIMARY KEY NOT NULL, Name TEXT NOT NULL, Head INTEGER NOT NULL CONSTRAINT fk_Physician_EmployeeID REFERENCES Physician(EmployeeID) ); CREATE TABLE Affiliated_With ( Physician INTEGER NOT NULL CONSTRAINT fk_Physician_EmployeeID REFERENCES Physician(EmployeeID), Department INTEGER NOT NULL CONSTRAINT fk_Department_DepartmentID REFERENCES Department(DepartmentID), PrimaryAffiliation BOOLEAN NOT NULL, PRIMARY KEY(Physician, Department) ); CREATE TABLE Procedure ( Code INTEGER PRIMARY KEY NOT NULL, Name TEXT NOT NULL, Cost REAL NOT NULL ); CREATE TABLE Trained_In ( Physician INTEGER NOT NULL CONSTRAINT fk_Physician_EmployeeID REFERENCES Physician(EmployeeID), Treatment INTEGER NOT NULL CONSTRAINT fk_Procedure_Code REFERENCES Procedure(Code), CertificationDate DATETIME NOT NULL, CertificationExpires DATETIME NOT NULL, PRIMARY KEY(Physician, Treatment) ); CREATE TABLE Patient ( SSN INTEGER PRIMARY KEY NOT NULL, Name TEXT NOT NULL, Address TEXT NOT NULL, Phone TEXT NOT NULL, InsuranceID INTEGER NOT NULL, PCP INTEGER NOT NULL CONSTRAINT fk_Physician_EmployeeID REFERENCES Physician(EmployeeID) ); CREATE TABLE Nurse ( EmployeeID INTEGER PRIMARY KEY NOT NULL, Name TEXT NOT NULL, Position TEXT NOT NULL, Registered BOOLEAN NOT NULL, SSN INTEGER NOT NULL ); CREATE TABLE Appointment ( AppointmentID INTEGER PRIMARY KEY NOT NULL, Patient INTEGER NOT NULL CONSTRAINT fk_Patient_SSN REFERENCES Patient(SSN), PrepNurse INTEGER CONSTRAINT fk_Nurse_EmployeeID REFERENCES Nurse(EmployeeID), Physician INTEGER NOT NULL CONSTRAINT fk_Physician_EmployeeID REFERENCES Physician(EmployeeID), Start DATETIME NOT NULL, End DATETIME NOT NULL, ExaminationRoom TEXT NOT NULL ); CREATE TABLE Medication ( Code INTEGER PRIMARY KEY NOT NULL, Name TEXT NOT NULL, Brand TEXT NOT NULL, Description TEXT NOT NULL ); CREATE TABLE Prescribes ( Physician INTEGER NOT NULL CONSTRAINT fk_Physician_EmployeeID REFERENCES Physician(EmployeeID), Patient INTEGER NOT NULL CONSTRAINT fk_Patient_SSN REFERENCES Patient(SSN), Medication INTEGER NOT NULL CONSTRAINT fk_Medication_Code REFERENCES Medication(Code), Date DATETIME NOT NULL, Appointment INTEGER CONSTRAINT fk_Appointment_AppointmentID REFERENCES Appointment(AppointmentID), Dose TEXT NOT NULL, PRIMARY KEY(Physician, Patient, Medication, Date) ); CREATE TABLE Block ( Floor INTEGER NOT NULL, Code INTEGER NOT NULL, PRIMARY KEY(Floor, Code) ); CREATE TABLE Room ( Number INTEGER PRIMARY KEY NOT NULL, Type TEXT NOT NULL, BlockFloor INTEGER NOT NULL, BlockCode INTEGER NOT NULL, Unavailable BOOLEAN NOT NULL, FOREIGN KEY(BlockFloor, BlockCode) REFERENCES Block ); CREATE TABLE On_Call ( Nurse INTEGER NOT NULL CONSTRAINT fk_Nurse_EmployeeID REFERENCES Nurse(EmployeeID), BlockFloor INTEGER NOT NULL, BlockCode INTEGER NOT NULL, Start DATETIME NOT NULL, End DATETIME NOT NULL, PRIMARY KEY(Nurse, BlockFloor, BlockCode, Start, End), FOREIGN KEY(BlockFloor, BlockCode) REFERENCES Block ); CREATE TABLE Stay ( StayID INTEGER PRIMARY KEY NOT NULL, Patient INTEGER NOT NULL CONSTRAINT fk_Patient_SSN REFERENCES Patient(SSN), Room INTEGER NOT NULL CONSTRAINT fk_Room_Number REFERENCES Room(Number), Start DATETIME NOT NULL, End DATETIME NOT NULL ); CREATE TABLE Undergoes ( Patient INTEGER NOT NULL CONSTRAINT fk_Patient_SSN REFERENCES Patient(SSN), Procedure INTEGER NOT NULL CONSTRAINT fk_Procedure_Code REFERENCES Procedure(Code), Stay INTEGER NOT NULL CONSTRAINT fk_Stay_StayID REFERENCES Stay(StayID), Date DATETIME NOT NULL, Physician INTEGER NOT NULL CONSTRAINT fk_Physician_EmployeeID REFERENCES Physician(EmployeeID), AssistingNurse INTEGER CONSTRAINT fk_Nurse_EmployeeID REFERENCES Nurse(EmployeeID), PRIMARY KEY(Patient, Procedure, Stay, Date) );
INSERT INTO Physician VALUES(1,'John Dorian','Staff Internist',111111111); INSERT INTO Physician VALUES(2,'Elliot Reid','Attending Physician',222222222); INSERT INTO Physician VALUES(3,'Christopher Turk','Surgical Attending Physician',333333333); INSERT INTO Physician VALUES(4,'Percival Cox','Senior Attending Physician',444444444); INSERT INTO Physician VALUES(5,'Bob Kelso','Head Chief of Medicine',555555555); INSERT INTO Physician VALUES(6,'Todd Quinlan','Surgical Attending Physician',666666666); INSERT INTO Physician VALUES(7,'John Wen','Surgical Attending Physician',777777777); INSERT INTO Physician VALUES(8,'Keith Dudemeister','MD Resident',888888888); INSERT INTO Physician VALUES(9,'Molly Clock','Attending Psychiatrist',999999999); INSERT INTO Department VALUES(1,'General Medicine',4); INSERT INTO Department VALUES(2,'Surgery',7); INSERT INTO Department VALUES(3,'Psychiatry',9); INSERT INTO Affiliated_With VALUES(1,1,1); INSERT INTO Affiliated_With VALUES(2,1,1); INSERT INTO Affiliated_With VALUES(3,1,0); INSERT INTO Affiliated_With VALUES(3,2,1); INSERT INTO Affiliated_With VALUES(4,1,1); INSERT INTO Affiliated_With VALUES(5,1,1); INSERT INTO Affiliated_With VALUES(6,2,1); INSERT INTO Affiliated_With VALUES(7,1,0); INSERT INTO Affiliated_With VALUES(7,2,1); INSERT INTO Affiliated_With VALUES(8,1,1); INSERT INTO Affiliated_With VALUES(9,3,1); INSERT INTO Procedure VALUES(1,'Reverse Rhinopodoplasty',1500.0); INSERT INTO Procedure VALUES(2,'Obtuse Pyloric Recombobulation',3750.0); INSERT INTO Procedure VALUES(3,'Folded Demiophtalmectomy',4500.0); INSERT INTO Procedure VALUES(4,'Complete Walletectomy',10000.0); INSERT INTO Procedure VALUES(5,'Obfuscated Dermogastrotomy',4899.0); INSERT INTO Procedure VALUES(6,'Reversible Pancreomyoplasty',5600.0); INSERT INTO Procedure VALUES(7,'Follicular Demiectomy',25.0); INSERT INTO Patient VALUES(100000001,'John Smith','42 Foobar Lane','555-0256',68476213,1); INSERT INTO Patient VALUES(100000002,'Grace Ritchie','37 Snafu Drive','555-0512',36546321,2); INSERT INTO Patient VALUES(100000003,'Random J. Patient','101 Omgbbq Street','555-1204',65465421,2); INSERT INTO Patient VALUES(100000004,'Dennis Doe','1100 Foobaz Avenue','555-2048',68421879,3); INSERT INTO Nurse VALUES(101,'Carla Espinosa','Head Nurse',1,111111110); INSERT INTO Nurse VALUES(102,'Laverne Roberts','Nurse',1,222222220); INSERT INTO Nurse VALUES(103,'Paul Flowers','Nurse',0,333333330); INSERT INTO Appointment VALUES(13216584,100000001,101,1,'2008-04-24 10:00','2008-04-24 11:00','A'); INSERT INTO Appointment VALUES(26548913,100000002,101,2,'2008-04-24 10:00','2008-04-24 11:00','B'); INSERT INTO Appointment VALUES(36549879,100000001,102,1,'2008-04-25 10:00','2008-04-25 11:00','A'); INSERT INTO Appointment VALUES(46846589,100000004,103,4,'2008-04-25 10:00','2008-04-25 11:00','B'); INSERT INTO Appointment VALUES(59871321,100000004,NULL,4,'2008-04-26 10:00','2008-04-26 11:00','C'); INSERT INTO Appointment VALUES(69879231,100000003,103,2,'2008-04-26 11:00','2008-04-26 12:00','C'); INSERT INTO Appointment VALUES(76983231,100000001,NULL,3,'2008-04-26 12:00','2008-04-26 13:00','C'); INSERT INTO Appointment VALUES(86213939,100000004,102,9,'2008-04-27 10:00','2008-04-21 11:00','A'); INSERT INTO Appointment VALUES(93216548,100000002,101,2,'2008-04-27 10:00','2008-04-27 11:00','B'); INSERT INTO Medication VALUES(1,'Procrastin-X','X','N/A'); INSERT INTO Medication VALUES(2,'Thesisin','Foo Labs','N/A'); INSERT INTO Medication VALUES(3,'Awakin','Bar Laboratories','N/A'); INSERT INTO Medication VALUES(4,'Crescavitin','Baz Industries','N/A'); INSERT INTO Medication VALUES(5,'Melioraurin','Snafu Pharmaceuticals','N/A'); INSERT INTO Prescribes VALUES(1,100000001,1,'2008-04-24 10:47',13216584,'5'); INSERT INTO Prescribes VALUES(9,100000004,2,'2008-04-27 10:53',86213939,'10'); INSERT INTO Prescribes VALUES(9,100000004,2,'2008-04-30 16:53',NULL,'5'); INSERT INTO Block VALUES(1,1); INSERT INTO Block VALUES(1,2); INSERT INTO Block VALUES(1,3); INSERT INTO Block VALUES(2,1); INSERT INTO Block VALUES(2,2); INSERT INTO Block VALUES(2,3); INSERT INTO Block VALUES(3,1); INSERT INTO Block VALUES(3,2); INSERT INTO Block VALUES(3,3); INSERT INTO Block VALUES(4,1); INSERT INTO Block VALUES(4,2); INSERT INTO Block VALUES(4,3); INSERT INTO Room VALUES(101,'Single',1,1,0); INSERT INTO Room VALUES(102,'Single',1,1,0); INSERT INTO Room VALUES(103,'Single',1,1,0); INSERT INTO Room VALUES(111,'Single',1,2,0); INSERT INTO Room VALUES(112,'Single',1,2,1); INSERT INTO Room VALUES(113,'Single',1,2,0); INSERT INTO Room VALUES(121,'Single',1,3,0); INSERT INTO Room VALUES(122,'Single',1,3,0); INSERT INTO Room VALUES(123,'Single',1,3,0); INSERT INTO Room VALUES(201,'Single',2,1,1); INSERT INTO Room VALUES(202,'Single',2,1,0); INSERT INTO Room VALUES(203,'Single',2,1,0); INSERT INTO Room VALUES(211,'Single',2,2,0); INSERT INTO Room VALUES(212,'Single',2,2,0); INSERT INTO Room VALUES(213,'Single',2,2,1); INSERT INTO Room VALUES(221,'Single',2,3,0); INSERT INTO Room VALUES(222,'Single',2,3,0); INSERT INTO Room VALUES(223,'Single',2,3,0); INSERT INTO Room VALUES(301,'Single',3,1,0); INSERT INTO Room VALUES(302,'Single',3,1,1); INSERT INTO Room VALUES(303,'Single',3,1,0); INSERT INTO Room VALUES(311,'Single',3,2,0); INSERT INTO Room VALUES(312,'Single',3,2,0); INSERT INTO Room VALUES(313,'Single',3,2,0); INSERT INTO Room VALUES(321,'Single',3,3,1); INSERT INTO Room VALUES(322,'Single',3,3,0); INSERT INTO Room VALUES(323,'Single',3,3,0); INSERT INTO Room VALUES(401,'Single',4,1,0); INSERT INTO Room VALUES(402,'Single',4,1,1); INSERT INTO Room VALUES(403,'Single',4,1,0); INSERT INTO Room VALUES(411,'Single',4,2,0); INSERT INTO Room VALUES(412,'Single',4,2,0); INSERT INTO Room VALUES(413,'Single',4,2,0); INSERT INTO Room VALUES(421,'Single',4,3,1); INSERT INTO Room VALUES(422,'Single',4,3,0); INSERT INTO Room VALUES(423,'Single',4,3,0); INSERT INTO On_Call VALUES(101,1,1,'2008-11-04 11:00','2008-11-04 19:00'); INSERT INTO On_Call VALUES(101,1,2,'2008-11-04 11:00','2008-11-04 19:00'); INSERT INTO On_Call VALUES(102,1,3,'2008-11-04 11:00','2008-11-04 19:00'); INSERT INTO On_Call VALUES(103,1,1,'2008-11-04 19:00','2008-11-05 03:00'); INSERT INTO On_Call VALUES(103,1,2,'2008-11-04 19:00','2008-11-05 03:00'); INSERT INTO On_Call VALUES(103,1,3,'2008-11-04 19:00','2008-11-05 03:00'); INSERT INTO Stay VALUES(3215,100000001,111,'2008-05-01','2008-05-04'); INSERT INTO Stay VALUES(3216,100000003,123,'2008-05-03','2008-05-14'); INSERT INTO Stay VALUES(3217,100000004,112,'2008-05-02','2008-05-03'); INSERT INTO Undergoes VALUES(100000001,6,3215,'2008-05-02',3,101); INSERT INTO Undergoes VALUES(100000001,2,3215,'2008-05-03',7,101); INSERT INTO Undergoes VALUES(100000004,1,3217,'2008-05-07',3,102); INSERT INTO Undergoes VALUES(100000004,5,3217,'2008-05-09',6,NULL); INSERT INTO Undergoes VALUES(100000001,7,3217,'2008-05-10',7,101); INSERT INTO Undergoes VALUES(100000004,4,3217,'2008-05-13',3,103); INSERT INTO Trained_In VALUES(3,1,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(3,2,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(3,5,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(3,6,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(3,7,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(6,2,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(6,5,'2007-01-01','2007-12-31'); INSERT INTO Trained_In VALUES(6,6,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(7,1,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(7,2,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(7,3,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(7,4,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(7,5,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(7,6,'2008-01-01','2008-12-31'); INSERT INTO Trained_In VALUES(7,7,'2008-01-01','2008-12-31');