开发者

Relational Algebra Query

开发者 https://www.devze.com 2023-04-09 21:21 出处:网络
I\'m stuck at the query below where i\'ll need to list out two attributes from different tables. Is there a simpler way to write the above query?

I'm stuck at the query below where i'll need to list out two attributes from different tables. Is there a simpler way to write the above query?

Tables:
Patient (PatientID, FamilyName, GivenName,Address) 
Item (ItemNo, Info, Fee)
Account (AccountNo, PatientID, Date)
AccountLine (AccountNo, ItemNo)

List the Item Info and the date of all treatments for any patient named John Wayne:

Select FamilyName =” Wayne” and GivenName=”John” (Patient)> Temp1
        Temp1*Temp1.PatientID = Account.PatientID (Account) > Temp2

 - Updated

Temp2*Temp2.AccountNo = AccountLine.AccountNo (Temp2 X Account) >Temp3
Temp3*Temp3.ItemNo = Item.ItemNo (Temp3x Item) > Temp4
Select Description, Date(开发者_JAVA技巧Temp4)

Join Answer 
Select Description, Date (Restrict FamilyName =” Wayne” and GivenName=”John” (Patient) Join Account Join Item Join AccountLine)


Looks very much like [homework] so I'll just provide hints...

Rather than selecting from a table, you can select from a join
specifically, the natural join of Patient and Account table would, for one, allow finding all AccountNo and Date values that are associated with John Wayne.
Similarly another join would locate the Item Info given the AccountNo.
And since a join can be joined with another one (assuming there are no conflicts), seems like I almost solved it...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号