Firefox 3

Setting up a database

And, indeed, there is a way to keep this data in good form. Firstly you should find what is the basic item of the database. Of course, it is a novel. Novel always has a title, but can have some (zero+) alternative titles as well. It has defined year of publishing and (in this case) main protagonist, though sometimes it can have none.–According to this analysis you should set main data file and move redundant data out of it, into separate files.

The said process is called normalization. If you want to learn more about data normalization (which is strongly advised!), you may read eg. Description of the database normalization basics from Microsoft Knowledge Base or excellent Mike Chapple's series at About:Databases website, that starts with Database Normalization Basics.

  novels.csv
  id|title|%aka|@protagonist|year
  1|The Mysterious Affair at Styles||1|1920
  2|The Murder on the Links||1|1923
  3|Poirot Investigates||1|1924
  4|The Murder of Roger Ackroyd||1|1926
  5|The Big Four||1|1927
  6|The Mystery of the Blue Train||1|1928
  7|The Murder at the Vicarage||2|1930
  8|Peril at End House||1|1932
  9|The Thirteen Problems|1|2|1932
  10|Lord Edgware Dies|2|1|1933
  11|Hercule Poirot's Christmas|3,4|1|1938
  12|The Body in the Library||2|1942
  (...)
  
  aka.csv
  id|aka
  1|The Tuesday Club Murders
  2|Thirteen at Dinner
  3|A Holiday for Murder
  4|Murder for Christmas
  (...)
  
  protagonist.csv
  id|protagonist
  1|Hercule Poirot
  2|Miss Marple
  3|Tommy and Tuppence
  4|Superintendent Battle
  5|Quin and Satterthwaite
  6|Parker Pyne

You now have a database in what they call "normalized form", i.e. without redundant data. Thus, when you find out that Miss Marple's given name was Natasha (I would be shocked if it was Natasha, though), you'll be able to add this information in one place only: in the third line of protagonist.csv file.

Please have a closer look at novels.csv header:

  id|title|%aka|@protagonist|year

% and @ signs mean that when you connect to novels.csv, aka.csv and protagonist.csv files (related tables) with the corresponding data from novels.csv will be read as well, and their data will be added to that from novels.csv.

Now you should include the script:

require $_SERVER['DOCUMENT_ROOT'] . '/path/to/pjjtextbase.php';

where /path/to/ means path to the directory where you put the pjjTextBase script file. You are now ready for your script to do some real work.