Project:
I am trying to create an on online search facility to dispense with the need to download a book shop’s daily XLS spreadsheet.
The spreadsheet has about 22,000 records in the following format:
Title: Mozart For a Merry Christmas
Author: Various
Ref: 463833
Type: CD
Baht: 150
Title: Angels, Arguments and a Furry Merry Christmas (Ally's World)
Author: McCombie, Karen
Ref: 454408
Type: Children
Baht: 190
Title: Merry Christmas, Geronimo! (Geronimo Stilton #12)
Author: Stilton, Geronimo
Ref: 478636
Type: Children
Baht: 90
### Online Demo
The spreadsheet is downloaded daily using CRON and converted into a MYSQL Database.
Currently the following books and SQL statement may be displayed using AJAX on
Entering “thanks giving”, without quotes, will search the books table using this query:
SELECT COUNT(*) AS `recNo`
FROM `booksQQQ`
WHERE
CONCAT
( `author`,`ref`,`memo`,`baht`,`type`, `qqq`)
LIKE '%thanks%'
AND
CONCAT
( `author`,`ref`,`memo`,`baht`,`type`, `qqq`)
LIKE '%giving%' ;
SELECT `author`,`ref`,`memo`,`baht`,`type`, `qqq`
FROM `booksQQQ`
WHERE
CONCAT
( `author`,`ref`,`memo`,`baht`,`type`, `qqq`)
LIKE '%thanks%'
AND
CONCAT
( `author`,`ref`,`memo`,`baht`,`type`, `qqq`)
LIKE '%giving%'
LIMIT 0, 42;
####And produce the following book:
Title: Thanksgiving on Thursday (Magic Tree House)
by: Osborne, Mary Pope
Baht: 70
Ref: #469961
Type: Children
### Indices The following two indices have been set on the books table:
$sql = 'ALTER TABLE `' .$tableName .'` ADD PRIMARY KEY(`id`);';
$sql = 'ALTER TABLE `' .$tableName .'` ADD UNIQUE KEY `ref` (`ref`)';
I am curious to know:
- if the search could be improved by adding a composite index
- or adding indexes for every searched field (6)
- or even another a completely new method of searching.