Supervision 2 Questions

  1. On our movie database, will the SQL query
   select person_id, movie_id, position
     from credits
     where not((not (position is null)) or position = 17);
  
return the same results as the query
   select person_id, movie_id, position from credits
    where position <> 17;
 
Explain your answer.
  1. Supppose that a and b are 3-valued expressions in SQL (true, false, or null). Can the expression (a and b) is null be rewritten as an equivalent boolean combination of a, b, a is null, and b is null?

  2. In boolean logic, the expressin not(a and b) always has the same value as (not a) or (not b). Is that true in 3-valued logic?

    What about the expression not(a or b) and the expression (not a) and (not b)?

    Is the expression a or (not a) always true in 3-valued logic? If not, can you extend this axiom to make it always true?

  3. Discuss the practical exercises for graph databases. Do you understand the queries and what they are doing?

  4. Our SQL tutorial presented several examples of LEFT JOIN such as

SELECT title, person_id
 FROM movies
 LEFT JOIN credits ON movie_id = id AND type = 'costume_designer';
 
In Cypher, that query can be written with an ``optional match`` as
   match (m:Movie)
    optional match (m)<-[:COSTUME_DESIGNER_FOR]-(p:Person)
    return m.title as title, p.person_id as person_id;
 
As with the ``LEFT JOIN,`` this returns a null value for ``person_id`` when there is no match in the ``optional match`` clause. How might we modify this query to only return the titles of movies that have no costume designer?