Dec 15

The Quandary of the Single Table Web Site

What do you do with sites that need a single table of data updated? These are sites which are totally static, except for this one thing…

For instance, we have a client for which we built a static site. But they have a page which lists all the locations where you can buy their stuff. This list changes a lot. They don’t want to keep calling (and paying) us to update this, so they want an interface where they can manage the list themselves. The list couldn’t be more simple — if you implement in SQL, it’s a flat, five-column database table.

This happens a lot — the sites are all static except for one element, be it a list of locations, events, the ubiquitous “Latest News,” etc. Some common themes

  1. The table is self-contained — it has no foreign keys to any other table (indeed, it’s the only table in the database). It is an island of data unto itself.
  2. The “objects” often extend past the “page” or “post” model (more fields are needed), so this precludes using a blogging system.
  3. You can do the display logic in some other manner. All you need is a way for the users to administer the data.
  4. Access is binary. One password gives the bearer access to the whole thing.

So what do you do? The idea is to do something as simple and fast as possible, with as little repetitive coding as you can get away with.

  • The most obvious solution is to build a little interface, but this goes against our stated goals. You have to program and debug a bunch of stuff for one little deal, which is a drag. Writing the same authentication and validation crap over and over gets a little tiring.

    BUT, if you generalize it and re-use it, then you’re in better shape. Instead of hard-coding the fields, pull them out of an ini file that contains their SQL field name, display title, data type, interface type, validation regex, etc. You’d need to refine it a bit, but you could dial it in tightly.

  • Related to the above, there are PEAR modules that strive to do just this. DB_DataObject with HTML_QuickForm, for instance. Propel for PHP5 is good too. But these are generally overkill, and they require a lot of code included on the backend.

  • I have great luck with PHPRunner and ASPRunner — we’ve talked about both of them before. These are little code-genning tools that spit out set of files to keep a table updated.

    The latest versions of these two tools are fantastic — they have WYSIWYG support and file uploads. They’re so handy, in fact, that it’s just as easy to have them manage 10 tables as it is to have them manage one.

    Additionally, I’ve been in contact with the developer, and he’s planning on developing an event model as well, so there’s an enourmous amount of functionality you could build with these. See this email exchange between he and I for some of the possibilities.

  • How about phpMyAdmin? Do you just let them loose with that?

  • Development frameworks like QCodo or Ruby would seem to make the maintenance of single tables pretty simple as well.

  • Do you even do it in a database? If you’re doing addresses (like in my example), could you give them a text file format and limited FTP access? Name on one line; then address on the next; then city, state, and zip; then skip a line before the next one.

    (I will admit to a crude hack for data I maintain myself: using PHP’s ini file format. I started using the parse_ini function, but then switched to one someone had written that was a little more robust. It gives you very simple access to a two-dimensional data set.)

So, how do you handle it?


Comments

by Brad Rhine,   December 15, 2005 10:16 AM  

I usually write a little desktop app (usually in REALbasic) to talk to the database and give them that. Quicker and easier to write and debug than a web app, and usually quicker for them to use.


by joe,   December 15, 2005 10:34 AM  

you could install a very simple CMS/blogging system - i'm thinking Wordpress here - and just integrate a page or two into the theme for the rest of your site. Then let them log into Wordpress and edit pages or stories in there.


by Deane,   December 15, 2005 10:46 AM  

you could install a very simple CMS/blogging system - i’m thinking Wordpress here

This is great for things that fit that data model, but what about things that don't? What if they want to maintain a list of Supreme Court cases, complete with about 10 extra fields of data.

(I can always manage to bring this topic up, can't I?)


by Deane,   December 15, 2005 10:50 AM  

I have updated the post with some "ground rules," just to save everyone from commenting on the same things over and over.


by ob,   December 15, 2005 11:03 AM  

You could use phpcodegenie for building a crud interface and it's done with a little styiling (if you want to).

or maybe qcodo, i saw the example video and it seems to generate code from the tables themselves.

however, code generation it's the way to go for.


by Peter Harkins,   December 15, 2005 11:06 AM  

Django with its auto-generated admin interface might be a good solution. It's at http://www.djangoproject.com, and if you skim pages 1 and 2 of the tutorial you'll see it in action. I'm using it for sites that non-technical users need to keep updated, and it's saved me tons of hours writing CRUD pages. It can be kind of a pain to config the webserver, though.


by Steve G,   December 15, 2005 11:28 AM  

How about using a simple PHP page editor like this Webpad?


by Ed,   December 15, 2005 11:34 AM  

I have great luck with PHPRunner and ASPRunner — we’ve talked about both of them before. These are little code-genning tools that spit out set of files to keep a table updated.

"You are not authorized to view this page"


by Deane,   December 15, 2005 11:51 AM  

I fixed the links. Sorry.


by argatxa,   December 15, 2005 12:14 PM  

I would get over the "I need a database for any kind of active content"

I would go for a text file and plug it somehow (name the method) in the required page.

How they want to maintain it is the key point.

On the easiest (and crappiest) way would be to have a place holder on the page and they can export their own tables from Excel or Word to html and upload it to the server.

  • From Excel to CVS and process it with PHP leaving a nice formatting
  • A single table maintenance page
  • XML and XSLT
  • ....

Not a big deal.. depends on how much developer time can afford...


by aadil,   December 15, 2005 12:20 PM  

CGI anyone? :)


by Adam Kalsey,   December 15, 2005 12:33 PM  

What if they want to maintain a list of Supreme Court cases, complete with about 10 extra fields of data.

Sounds like that application falls a bit outside your stated goals here. See http://kalsey.com/2005/12/thedangerofdoingtoo_much/


by bbassin,   December 15, 2005 12:48 PM  

How about Macromedia Contribute? Cheap, easy to use and very flexible. Build the template once and hand the editing tool over to the client.


by Deane,   December 15, 2005 1:14 PM  

Sounds like that application falls a bit outside your stated goals here.

No it's not. One table, several columns (plaintiff, defendant, year, ruling, vote, who wrote the opinion, etc.), many rows. This is exactly what I'm talking about.

Yes, you can get much more complicated with it, but -- for the purposes of this example -- let's not.


by Deane,   December 15, 2005 1:23 PM  

they can export their own tables from Excel or Word to html and upload it to the server.

We've talked about using Office for content management like this in a couple places:

  1. Microsoft Excel as a Simple Content Storage Mechanism

  2. Pitching SQL Spitballs

  3. Access as a Client-Side CMS

I do like your "export from Word then include the file" method. That could be a winner for a lot of things.


by Derek,   December 15, 2005 3:03 PM  

A simple approach for small amounts of data is to store the PHP array using PHP's serialize, and then unserialize it as needed, store it in session. when the session times out the array goes away.

Everyone is going to yell when I say this, but if there are not a huge number of records you could also use XML. This presumes that the developer knows there way around XML, XSL, XPath, XQuery; which I do, so no problem.


by Deane,   December 15, 2005 3:09 PM  

Yeah, PHP serialization is handy. But, this just addresses the data storage. How about the interface? No matter how you store the database, you still have to build an interface.


by Bilby,   December 15, 2005 5:35 PM  

When I've had to do this sort of job, normally I've just saved the data in a text file either using XML (if I had a parser on hand or felt like throwing a small one togeather) or a standard "config-style" format. The interface, then, is very simple: a simple form which has the fields to update and a password box for simple authentication. The password is hardcoded (and encrypted) into the PHP file that updates the text file. That PHP file doesn't care what the fields are - it just takes the field name, takes the content, and uses that to construct the data file, without caring what they are (although wit enogh security to make sure that we're not getting any nasty stuff sneaking in). The whole job normally takes about 15 minutes to code - maybe 30 if I haven't had my caffine yet.

I wouldn't bother with a database, as it is too much like overkill, as is a complex authentication system. And I like phpMyAdmin, but I would never let most of my clients near it. :)


by Vinod Kulkarni,   December 16, 2005 3:50 AM  

Several Wiki systems allow you to create and publish a static site from wiki editable contents . (For example, twiki has a plugin for this.) But installing a wiki at customer site is not usually an option - especially when all they want is a static site.

However, website provider could use wiki to produce the site and create a static version. With some additional enhancements, this static version could also include some standard HTML interfaces (along with relevant scripts) to update structured parts of web pages.

Such a publishing feature would further enhance value of wiki systems...


by Bilby,   December 16, 2005 3:52 AM  

I should add - a few times, I've stord the data directly in the HTML file. By using specialised comments tags, you can parse the HTML file to grab the data. The have a PHP interface (normally a single file) allow editing of the HTML page. It is a tad odd, but it has the advantage that clients can edit the HTML in Dreamweaver if they want, and so long as the comments remain intact the interface will still work for updating. You also don't have to manage a separate data file, and the page doesn't need to be parsed when requested. It was probably a dumb idea, but it was fun, especially when extended dramatically, and worked well pre-PHP.


  • There are 23 comments on this entry.
  • 20 comments have been displayed above.
Load the next 20 comments.

Add Comment


Want to advertise on this site? Contact FM.
Web Hosting Web hosting, dedicated servers and Web design services
Laser Toner Cartridges UK laser toner, toner cartridges, hp toner, lexmark toner, samsung toner, canon, toner, epson toner, oki toner, kyocera toner, xerox toner, remanufactured toner, compatible toner
Direct TV Deals Free 4 room direct tv deals. no equipment to buy. free fast professional direct tv installation. this is the best direct tv deal available anywhere.
SEO Article Learn from the experts with our SEO article.
rope light Shopping with birddog distributing, inc., gives you access to the lowest prices, the best customer service and the quickest delivery times possible.
Laptop AC Adapter We offer genuine factory direct replacement AC adapters.
Direct TV Best satellite TV deals.
Direct TV Deals Direct TV programming deals are varied and include packages containing from 50 channels up to over 250 channels.
8mm film to DVD Retain family memories with the only frame by frame digital restoration service in the United States for your 8mm film to DVD today
Rubber Stamp Shop for custom self-inking stamps, hand stamps, address stamps, label stamps, check endorsement stamps, check deposit stamps, date stamps, pre inks, pocket stamps, ink and much more!