-
Relational Algebra
Given : LIKE(person, course), TAKING(person, course), and DISLIKE(person, course). Also assume that a person likes at least one course and dislike at least one course as well. We also assume that a course is taken by at least one person.
List the people that are taking all the courses they like. Express in relational algebra.
I've spent a long time looking at this problem and cannot figure it out. I realize if there was one person, I can easily find most questions that ask "all" but in this case, I cannot figure it out because it is more than one person.
-
Just to understand you clearly, LIKE , TAKING, DISLIKE are tables? person and course are varchars?
-
Yes, they are tables. It does not matter whether they integer or varchars, the answer is wanted in relational algebra.
-
How about this, does use a view though.
Code:
CREATE VIEW [nonlikes]
AS
SELECT person,course FROM taken
EXCEPT
(SELECT person,course FROM taken
INTERSECT
SELECT person,course FROM likes)
SELECT DISTINCT person FROM taken except
SELECT DISTINCT person FROM nonlikes
-
Gil-Galad, thanks for the help but that is not in relational algebra.
-
Can You Better Explain
Can you better explain what you are asking? It is a little unclear what exactly you want.
-
Not entirely sure
Perhaps something like this?
πT.person(Likes⋈Taking⋈Dislikes)/πT.person(Likes⋈Taking)
It might require a -πT.person(Dislikes⋈Taking) but am not entirely sure as I am not exactly an expert at this. Hope it helps though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|