Little to no expectations, after all it's a holiday! (and I didn't even post this update on time)
[:find (count ?movie)
:where
[?movie :movie/title]]
[:find (min ?date)
:where
[_ :person/born ?date]]
Exercise 2: Given a collection of actors and (the now familiar) ratings data. Find the average rating for each actor. The query should return the actor name and the avg rating.
[:find ?name (avg ?rating)
:in $ [?name ...] [[?title ?rating]]
:where
[?p :person/name ?name]
[?m :movie/title ?title]
[?m :movie/cast ?p]]
Exercise 0: Write a rule [movie-year ?title ?year] where ?title is the title of some movie and ?year is that movies release year.
[[(movie-year ?title ?year)
[?m :movie/year ?year]
[?m :movie/title ?title]]]
Exercise 1: Two people are friends if they have worked together in a movie. Write a rule [friends ?p1 ?p2] where p1 and p2 are person entities. Try with a few different ?name inputs to make sure you got it right. There might be some edge cases here.
[[(friends ?p1 ?p2)
[?m :movie/cast ?p1]
[?m :movie/cast ?p2]
[(not= ?p1 ?p2)]]
[(friends ?p1 ?p2)
[?m :movie/cast ?p1]
[?m :movie/director ?p2]]]
I am glad I finished Learn Datalog Today, the last two chapters were more difficult that the previous ones, took longer than expected. If the $25 are not claimed, I'll donate the rest to a charity.