Build Your Own Database 2

Join two tables

A second table, 'writers' has been added to the database along with 'stories'. Each story record contains a foreign key, 'writer' that points to the 'writers' table.

However, there can be multiple stories for each writer. To manage this many-to-one relationship, a third table is needed. I use an array as a 'map' to hold pairs of record keys. If more tables are added to the database, more maps can be created to join them.

An addional set of database functions is used to access these map arrays:

Files and Folders for this demo:

top level file structure for SMALL2 application

Contents of the 'data' folder
data folder for the small2 demo website

Contents of the 'writers' sub-folder

Contents of the 'stories' sub-folder

Contents of the 'pages' folder:

Contents of the 'admin-pages' folder

Contents of the 'inc' folder:

'index.php' file