Monday, March 26, 2012

Relational Algebra & SQL newbie needs help!

I have been posed and attempted to answer several questions but I do not seem to be getting anywhere. I have emailed my tutor a week ago and he has not responded, If anyone can take a look and help me out I would be grateful.
Two of the questions are below, if anyone can help with these two I'm sure that I can crack the rest!

Find the first name, surnames and address of the patients that have had at least one operation with broken bones.

SQL:

REL1=SELECT FROM Operation WHERE OperationType LIKE Broken%
REL2=Patient NATJOIN REL1 with PatientCode common.
REL3=PROJECT REL2 OVER PatientSurname, PatientFirstname, PatientAddress.

Relational Algebra:

σ operationtype = broken*(operation)
patient |x| operation
∏ patientsurname, patientfirstname, patientaddress (patient)

[I]Find the details of all patients that have shared any doctors with the patient that has the code P57". [/I]

SQL:

REL1=Operation NATJOIN Is_Seen_By with PatientCode common.
REL2=SELECT DoctorCode FROM REL1 WHERE PatientCode=P57.
REL3=Operation NATJOIN REL2 WHERE DoctorCode common.
REL4=Is_Seen_By NATJOIN REL3 WHERE DoctorCode common.
REL5=Patient NATJOIN REL4 with PatientCode common.
REL6=PROJECT REL5 OVER PatientCode, PatientSurname, PatientFirstname, PatientAddress, PatientSex, PatientAge, PatientOccupation, PatientHeight, PatientWeight.

Relational Algebra:

operation |x| is_seen_by
σ doctorcode ^ patientcode = p57(operation |x| is_seen_by)

(I can't get my head around this query at all, hence the lack of algebra)

Thanks.Bump. Please Help Me!|||Maybe these guys can help you.|||Thanks for the move, anyone got any help to offer? I'm really stuck on this one.

No comments:

Post a Comment