关系代数帮助

发布于 2024-10-11 14:20:49 字数 659 浏览 2 评论 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 日已完成且成功的操作的代码。另请列出参与手术的医生姓名。

I'm new to relational algebra and finding it difficult. I've answered a few questions; however, they where relatively simple. Could do with help with these though.

Database

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)

Queries

  1. Find the surname and gender of the patients that have been operated on by doctor "DR333" and results have not been successful.

  2. Find the code of the operations that have been done on the 18th of November 2010 and have been successful. Please also list the name of the doctors which were involved with the operation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自控 2024-10-18 14:20:50

这可能是完全错误的,也可能不是完全错误的,我刚刚结束了很长的计算机休假。它的 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"

This may or may not be totally wrong, I'm back from a very long computer sabbatical. The SQL for it should be something like:

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文