As many of you readers know one of the biggest reasons for me to move off of .org to a selfhosted solution was to be able turn my tables into handy generators. A couple of other reasons of course include the following:
tables in posts can now be autogenerated, and can be fleshed out easily.
tables can be dumped straight into a .pdf file for easy printing and travel.
automattic generation of .tab files for tablesmith
Now this is not my first time at the php/sql rodeo. Various other projects spaced convienently many years apart have had cms components with all the nifty sql. But I’ve never really had plans to make it the db so versatile. I discovered while working on the ale generator that my first database schema was not very updateable.
What’s your take on this:
PrimaryKey, subTable, Header, tableItem, itemDescription
1, aleStyle, 1, Styles of Ale, A Table of Ale styles
2, aleStlyle, 0, Lager, Bottom Barrel yeast. Often fermented cold
Then I use this query when pulling data for the generator:
SELECT * FROM ‘aleGenerator’ WHERE subTable = ‘aleStyle’ AND ‘Header’ = 0 ORDER BY RAND() LIMIT 1
What do you think? Ideas on a better schema? Better query?