-1

使用以下关系:

consultant(id,Name,Skill) 

CustomerCompany(Id,name Address, Phone, Email, WebAddr,Market)

project(id,StartDate,EndDate,ConsultantID,CustomerId,Days)

Invoice(id,Date,Customer,Amount,Status)

我正在尝试使用 SQL 和关系代数来解决以下场景

查找顾问的姓名和客户的姓名,顾问曾在哪里为客户工作,客户收到的发票金额在 10 万到 20 万英镑之间

使用 SQL 我有:

选择 I.amount, C.name from CustomerCompany C, Invoice I where I.Customer=C.id and >all(选择 C.name, Con.Name from CustomerCompany, Con Consultant where i.amount 介于 100 和 200 之间);

关系代数:

amount = σ(Invoice, amount>=100 and amount<=200)

joininv= Ⓧ(amount, Customer, CustomerCompany, id)

joincon Ⓧ(joiniv, Consultant id, Project, ConsultantID)

π =(joincon, name, Name)

我想知道是否写错了?

谢谢你的帮助!

4

1 回答 1

0

这会成功的

select 
con.Name
from CustomerCompany CustComp
inner join project PRO on PRO.CustomerId=CustComp.Id
inner join consultant con on con.id=PRO.ConsultantID
inner join Invoice Inv on Inv.Customer=CustComp.name
where Inv.Amount between 100 and 200

加入

于 2013-05-09T17:31:11.810 回答