5.考虑以下库架构
Books (book_no,title,authors,publisher)
Borrower(borrower_id, name, DOB, job)
Borrowed(borrower_id,book_no,date)
在关系代数中编写以下查询
答案 0 :(得分:0)
根据你的问题,sql查询就像这样
问题1
select B.borrower_id, B.name
from Borrower as B, Borrowed as Bw, Books as Bk
where B.borrower_id = Bw.borrower_id
and Bw.book_no = Bk.book_no
and Bk.publisher = 'Wiley'
group by B.borrower_id, B.name
having count(Bw.borrower_id) > 3
问题2
select B.name
from Borrower as B, Borrowed as Bw, Books as Bk
where B.borrower_id = Bw.borrower_id
and Bw.book_no = Bk.book_no
and Bk.publisher = 'Wiley'
group by B.name
问题3
select B.borrower_id, B.name, count(Bw.borrower_id) as cnt
from Borrower as B, Borrowed as Bw, Books as Bk
where B.borrower_id = Bw.borrower_id
and Bw.book_no = Bk.book_no
group by B.borrower_id, B.name