How to find all pizzerias that serve every pizza eaten by people over 30?

后端 未结 9 2026
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 07:29

I\'m following the Stanford Database course and there\'s a question where we have Find all pizzerias that serve every pizza eaten by people over 30 using Re

9条回答
  •  臣服心动
    2020-12-29 07:54

    Definitely this is the concept of division operator in relational algebra.

    But I tried on that course. The RA Relational Algebra Syntax doesn't support dev operator. So I used diff and cross instead. Here is my solution:

    \project_{pizzeria}(Serves)
    \diff
    \project_{pizzeria}(
        (\project_{pizzeria}(Serves) 
        \cross 
        \project_{pizza}(\project_{name}(\select_{age>30}(Person))\join Eats))
        \diff
        \project_{pizzeria,pizza}(Serves)
    )
    

提交回复
热议问题