Results 1 to 7 of 7

Thread: Relational Algebra

  1. #1
    Join Date
    Feb 2011
    Posts
    3

    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.

  2. #2
    Join Date
    Feb 2011
    Location
    Melbourne, Australia
    Posts
    13
    Just to understand you clearly, LIKE , TAKING, DISLIKE are tables? person and course are varchars?

  3. #3
    Join Date
    Feb 2011
    Posts
    3
    Yes, they are tables. It does not matter whether they integer or varchars, the answer is wanted in relational algebra.

  4. #4
    Join Date
    Feb 2011
    Location
    Melbourne, Australia
    Posts
    13
    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

  5. #5
    Join Date
    Feb 2011
    Posts
    3
    Gil-Galad, thanks for the help but that is not in relational algebra.

  6. #6
    Join Date
    Sep 2011
    Posts
    2

    Can You Better Explain

    Can you better explain what you are asking? It is a little unclear what exactly you want.

  7. #7
    Join Date
    Oct 2011
    Posts
    2

    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
  •