Check out CodeQL, it's a modern relational query language based on Datalog.