Exposing the three tables to SQL