Putting it all together
In this exercise, we are going to use many of the techniques and concepts we learned throughout the course to generate a data set that we could use to predict whether the words and phrases used to describe a film have an impact on the number of rentals.
First, you need to create a tsvector
from the description
column in the film
table. You will match against a tsquery
to determine if the phrase "Astounding Drama" leads to more rentals per month. Next, create a new column using the similarity
function to rank the film descriptions based on this phrase.
This exercise is part of the course
Functions for Manipulating Data in PostgreSQL
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Select the title and description columns
SELECT
title,
description
FROM
film
WHERE
-- Match "Astounding Drama" in the description
___(___) ___
to_tsquery('Astounding & Drama');