تمرين 2 از بحث جبر رابطه اي درس پايگاه داده ها
تمرين ۲
متن زير كه شامل ۱۰ سوال به زبان انگلیسی است را به زبان فارسي ترجمه نماييد
و سپس با استفاده از عملگرهای جبر رابطه ای به سوالات مربوطه پاسخ دهید
اين سوالات از جداول تمرين ۱ طراحي شده است
تحليل خود را براي هر سوال بيان كنيد (الزامي)
Consider the following relation schemes:
Patients = {p-id, p-name, street, city, state, zip}
Doctors = {d-name, d-phone, specialty}
Visits = {d-name, p-id, time, day, month, year, fee}
Accounts = {p-id, date-in, date-out, amount}
Write the following queries in relational algebra:
Q1 List id and names of patients who live in High Point.
مثال حل شده برای سوال اول
این سوال لیست شماره شناسایی و نام بیمارانی را می خواهد که در بالای شهر(High point) زندگی می کنند

تحلیل:چون شماره شناسایی و نام بیماران را می خواهد باید خروجی دارای دو ستون باشد(p-id, p-name) پس از عملگر پرتو برای اینکار استفاده می شود و شرط مورد نظر (شهر = بالای شهر) توسط عملگر گزینش مشخص می شود و تمام این عملگر ها فقط بر روی جدول بیماران(Patients ) باید اعمال شود در نتیجه جبر رابطه ای آن به صورت فوق است.
Q2 List the details of all visits for which a fee of $400 or more was charged.
Q3 List the account details for patient with id ``123456''. Can the total (i.e. sum of amounts) be calculated in relational algebra?
you can use relational algebra by extending it to include aggregate operations such as sum.
The operation sum will take a collection of numbers and return a single value.
Q4
List all patients (id and name) visited by Dr. Smith in July and August 1998.
راهنماییQ4 :دوجدول Patients و visits باید پیوند طبیعی داده شوند و سپس عملگر ها را اعمال کنید
Q5 List doctors who have not visited ``Tom Holiday''.
راهنماییQ۵ : از عملگر تفریق استفاده کنید.
Q6 List pairs of doctors (names) with the same specialty.
Q7 List patients (id) who have been visited by all doctors.
راهنماییQ۷ : از عملگر تقسیم استفاده نمایید.
Q8 List patients admitted on or before 08/15/98 who were visited by Dr. Smith during their hospitalization. (Assume comparison is possible on dates.)
راهنماییQ۸ : سه جدول باید با هم پیوند طبیعی برقرار کنند.
Q9
List doctors who have been themselves hospitalized. Are you making any assumptions in formulating your query?
I am assuming that the p-name and d-name fields uniquely identify doctor or patient.
Q10 List the doctor who has charged the highest fee (ever).
وبلاگ تخصصي