开发者

Help to translate SQL query to Relational Algebra

开发者 https://www.devze.com 2022-12-22 23:10 出处:网络
I\'m having some difficulties with translating some queries to Relational Algebra. I\'ve a great book about Database Design and here is a chapter about Relational Algebra but I still seem to have some

I'm having some difficulties with translating some queries to Relational Algebra. I've a great book about Database Design and here is a chapter about Relational Algebra but I still seem to have some trouble creating the right one:

开发者_运维知识库Thoes queries I've most difficuelt with is these:

SELECT COUNT( cs.student_id ) AS counter
FROM course c, course_student cs
WHERE c.id = cs.course_id
AND c.course_name = 'Introduction to Database Design'

SELECT COUNT( cs.student_id ) 
FROM Course c
INNER JOIN course_student cs ON c.id = cs.course_id
WHERE c.course_name = 'Introduction to Database Design'

and

SELECT COUNT( * ) 
FROM student
JOIN grade ON student.f_name = "Andreas"
AND student.l_name = "Pedersen"
AND student.id = grade.student_id

I know the notation can be a bit hard to paste into HTML forum, but maybe just use some common name or the Greek name.

Thanks in advance Mestika


"and here is a chapter about Relational Algebra"

Where ??? This doesn't seem to point to anything.

At any rate, the examples you give are examples of what the literature-with-an-algebraic-perspective usually calls "aggregations", or "summaries", or some such.

In contrast with the "basic" operators such as JOIN, PROJECT, etc., the consensus on how to deal with such "aggregate operators" is relatively small. Keep in mind that there is no such thing as "the" relational algebra, and that different implementations are completely free to choose which set of algebraic operators they make available to their users !!!

0

精彩评论

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