liveBook · Manning

Keyword query

As explained in Grokking Relational Database Design

Keyword searching is a query technique that finds records containing specified words or terms in text.

A keyword query finds movie records containing specified words or terms. For title searches that need partial-word or typo-tolerant matching, use a full-text index rather than relying only on a standard index. section 7.9

Use keyword searching when the application needs to:

  • Find titles containing a word or term. section 7.9
  • Support partial-word matching or fuzzy searching for misspellings. section 7.9
  • Keep text searches efficient as the data grows. section 7.9

Searching movie titles

A basic search uses `WHERE title LIKE '%exciting%'`. A full-text search adds an index and uses `MATCH(title) AGAINST('exciting' IN NATURAL LANGUAGE MODE)`, making the same task more efficient. section 7.9

-- comment: works for MySQL and MariaDB
-- comment: consult ChatGPT on adaptations 
-- comment: for other RDBMS
-- comment: add a full-text index
CREATE FULLTEXT INDEX ft_idx_title
 ON movie (title);
-- comment: search
SELECT *
 FROM movie
 WHERE MATCH(title)
 AGAINST('exciting' IN NATURAL LANGUAGE MODE);

Inspect the MySQL and MariaDB full-text index and search commands for the movie title example. section 7.9

How Grokking Relational Database Design covers it

How deep it goes
Defines token-based full-text indexes, contrasts LIKE searches, and shows MySQL, MariaDB, and PostgreSQL implementations.
Examples
Uses movie titles, LIKE '%exciting%', and MATCH ... AGAINST('exciting' IN NATURAL LANGUAGE MODE).
What you can do after
Apply it via full-text indexes and database-specific search syntax for movie-title queries.
How it connects
Connects keyword searching with full-text indexes, partial-word matching, fuzzy searching, and query performance.

Also explained in

Compare how 3 books explain keyword query →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Relational Database Design. The section links point to the parts of the book it draws on.