0

我是关系代数的新手,发现它很困难。我已经回答了几个问题;但是,它们相对简单。虽然可以帮助解决这些问题。

数据库

Patient (PatientCode, PatientSurname, PatientFirstname, PatientSex, PatientAge,
         PatientOccupation, PatientHeight, PatientWeight, PatientAddress) 

Doctor (DoctorCode, DoctorSurName,  DoctorFirstName, DoctorPrivateAddress,
        MobileNo, Doctor Specialisim) 

Operation (Operation Code, PatientCode, DoctorCode, Date, Time, Result,
           OperationType) 

Is_Seen_By (PatientCode, DoctorCode, Date, Time)

查询

  1. 查找医生“DR333”做过手术且结果不成功的患者的姓氏和性别。

  2. 找到在 2010 年 11 月 18 日完成并成功的操作的代码。还请列出参与手术的医生的姓名。

4

1 回答 1

0

这可能完全错误,也可能不完全错误,我从一个很长的计算机休假回来了。它的 SQL 应该是这样的:

Q1:

SELECT Patient.PatientSurname, Patient.PatientSex
  FROM Patient INNER JOIN Operation
    ON Operation.PatientCode = Patient.PatientCode
 INNER JOIN DOCTOR ON Operation.DoctorCode = Doctor.DoctorCode
 WHERE Operation.Result = "fail"
   AND Doctor.DoctorCode = "DR333"

Q2:

SELECT Operation.OperationCode, Doctor.DoctorFirstName
  FROM Operation INNER JOIN Doctor ON Operation.DoctorCode = Doctor.DoctorCode
 WHERE Operation.Date = "18/11/2010"
   AND Operation.Result = "success"
于 2011-01-13T00:18:26.467 回答