--- Q1 
--- Carrie Fisher's ID number

SELECT Actor_ID
FROM nza.Actor
WHERE Name = 'Carrie Fisher';


--- Q2
--- people who acted in the same movie with Carrie Fisher

SELECT DISTINCT Name
FROM nza.Actor 
WHERE Actor_ID IN --- 0 degree of separation
   (SELECT Actor_ID
    FROM nza.Part
    WHERE Movie_ID IN
      (SELECT Movie_ID
       FROM nza.Part
       WHERE Actor_ID IN
          (SELECT Actor_ID
           FROM nza.Actor
           WHERE Name = 'Carrie Fisher')));

--- Q3 
--- same without nested queries

SELECT DISTINCT Actor1.Name
FROM nza.Part Part1, nza.Part Part2, nza.Actor Actor1, nza.Actor Actor2
WHERE Part1.Movie_ID = Part2.Movie_ID
      AND
      Part1.Actor_ID = Actor1.Actor_ID
      AND
      Part2.Actor_ID = Actor2.Actor_ID
      AND
      Actor2.Name = 'Carrie Fisher';


--- Q4
--- one degree of separation:

SELECT DISTINCT Name
FROM nza.Actor
WHERE Actor_ID IN
   (SELECT Actor_ID
    FROM nza.Part
    WHERE Movie_ID IN
      (SELECT Movie_ID
       FROM nza.Part
       WHERE Actor_ID IN --- those with 0 degree of separation
             (SELECT Actor_ID
              FROM nza.Part
              WHERE Movie_ID IN
                  (SELECT Movie_ID
                   FROM nza.Part
                   WHERE Actor_ID IN
                      (SELECT Actor_ID
                       FROM nza.Actor
                       WHERE Name = 'Carrie Fisher')))));


--- Q5
--- two degrees of separation:

SELECT DISTINCT Name
FROM nza.Actor
WHERE Actor_ID IN
   (SELECT Actor_ID
    FROM nza.Part
    WHERE Movie_ID IN
      (SELECT Movie_ID
       FROM nza.Part
       WHERE Actor_ID IN --- those with 1 degree of separation
          (SELECT Actor_ID
           FROM nza.Part
           WHERE Movie_ID IN
              (SELECT Movie_ID
               FROM nza.Part
               WHERE Actor_ID IN --- those with 0 degree of separation
                  (SELECT Actor_ID
                   FROM nza.Part
                   WHERE Movie_ID IN
                       (SELECT Movie_ID
                        FROM nza.Part
                        WHERE Actor_ID IN
                           (SELECT Actor_ID
                            FROM nza.Actor
                            WHERE Name = 'Carrie Fisher')))))));


